Skip to content

discordMessageManager

javis86 edited this page Mar 11, 2023 · 10 revisions

Introduction

The discordMessageManager provides multiple ways to interact with messages in Discord. The current features are:

  • Send messages to a Discord Channel.
  • Send private messages to users.
  • Edit messages in Discord Channels.
  • React to messages.
  • Publish messages to announcement channel.
  • Delete messages in Discord Channels.
  • Add attachments to messages.
  • Add components like buttons, text inputs and select menus to messages.

Currently it's not possible to edit or delete private messages. Nor is it possible to add an attachment to a message when editing it.

Inputs

These are all the inputs this node takes. Below are specifc examples for use cases which also shows what variables are required for that action.

Input Type Options Description
msg.action String create, edit, reply, react, crosspost and delete The action you wish to perform. When not set create is default.
msg.payload String The string you wish to send or the new content of a message when editing.
msg.channel String or Object The channel ID or a channel Object that contains the ID. Required when sending, editing or deleting in a channel.
msg.user String or Object The user ID or a user Object that contains the ID. Required when sending a message to a user.
msg.message String or Object The message ID or a message Object that contains the ID. Required when editing or deleting a message.
msg.embeds Object or Array An embed object or an array of embed objects.
msg.attachments String, Object or Array A location to an attachment. Can be online by URL, an object with a buffer payload or a file in the local filesystem.
msg.timedelay Number The time in milliseconds to wait before deleting a message.
msg.components Array An array of component objects.

Sending a message to a channel

To send messages to a Discord channel these variables are required:

Input Type Description
msg.payload String The content you wish to send.
msg.channel String or Object The channel ID or a channel Object that contains the ID. Required when sending, editing or deleting in a channel.

The following variable is optional:

Input Type Description
msg.attachments String, Object or Array A location to an attachment. Can be online by URL, an object with a buffer payload or a file in the local filesystem.

Sending a message to a user

To send private messages to a user the following variables are required:

Input Type Description
msg.payload String The content you wish to send.
msg.user String or Object The user ID or a user Object that contains the ID. Required when sending a message to a user.

The following variable is optional:

Input Type Description
msg.attachments String, Object or Array A location to an attachment. Can be online by URL, an object with a buffer payload or a file in the local filesystem.

Sending an embed message

To send embeds you can follow the same procedure as sending a message to a channel or user. However the following changes are required:

Input Type Description
msg.embeds Object or Array This needs to be an embed Object or Array of embed Objects. Find out how to create this here.

Editing a message in a Discord channel

Editing messages is currently only possible in channel, so it's not possible for private messages. The required variables are:

Input Type Description
msg.action String Needs to be set to 'edit'.
msg.payload String The new content of the message.
msg.channel String or Object The channel ID or a channel Object of the channel where the message is.
msg.message String or Object The message ID or a message Object of the message you wish to delete.

It's currently not possible to add an attachment when editing a message.

Editing embeds

To edit an existing embed message or change a normal message into an embed, follow the same procedure as shown above with normal message editing. However the following changes are required:

Input Type Description
msg.embeds Object or Array This needs to be an embed Object or Array of embed Objects. Find out how to create this here.

Deleting a message in a Discord channel

Deleting messages is currently only possible in channel, so it's not possible for private messages. The required variables are:

Input Type Description
msg.action String Needs to be set to 'delete'.
msg.channel String or Object The channel ID or a channel Object of the channel where the message is.
msg.message String or Object The message ID or a message Object of the message you wish to delete.

Sending a component array

To send buttons, text inputs and select menus you can follow the same procedure as sending a message to a channel or user. However the following changes are required:

Input Type Description
msg.components Array This needs to be an Array of component Objects. Find out how to create this here.

Replying a message in a Discord channel

Replying messages is currently only possible in channel, so it's not possible for private messages. The required variables are:

Input Type Description
msg.action String Needs to be set to 'reply'.
msg.payload String The message for the reply.
msg.channel String or Object The channel ID or a channel Object of the channel where the message is.
msg.message String or Object The message ID or a message Object of the message you wish to reply.

Reacting to a message in a Discord

Add a reaction to a message.

Input Type Description
msg.action String Needs to be set to 'react'.
msg.payload String Unicode of emoji or custom guild emoji name.
msg.channel String or Object The channel ID or a channel Object of the channel where the message is.
msg.message String or Object The message ID or a message Object of the message you wish to react to.