Skip to main content

Message

Everything you do with a single message: catch it when it arrives, read it, reply, edit, delete, pin and react.

Show the whole Message flyout

The Message subcategory

Catching a message​

When a message is received

when a message is received fires for every message in every channel your bot can see, including messages from other bots and from your own bot.

When a message is received from a human

when a message is received from a human is the same event with bot messages filtered out. Use this one unless you specifically want to react to bots. It saves you an if and prevents the classic loop where your bot replies to itself forever.

Message received

Inside any of these events, message received is the message itself.

When the bot receives a DM​

When the bot receives a DM

when the bot receives a DM fires when someone sends your bot a direct message. Messages sent in servers are ignored, and so are messages from bots, so replying to a DM won't make your bot answer itself.

Use message received inside it just like the other message events. content of the message, channel of the message and the reply blocks all work here, and get author (user) of message received gives you the person who sent the DM. There is no server or member in a DM, so blocks that read the server or the member who sent the message don't belong in this event.

Reading a message​

Message property

One block with a dropdown covers the common properties: content, author (user) and channel.

BlockReturns
is replyTrue when the message is a reply to another.
reply toThe message it replied to.
reply pingWhether the reply pinged the person being replied to.

Getting a specific message​

Get message by ID

get the message with id equal to ... on the channel ... fetches a message you know the ID of. Enable Developer Mode in Discord to copy a message ID from the right-click menu.

To fetch several at once, use get last ... messages of channel from Channels.

Sending and editing​

BlockWhat it does
reply to messageReplies to the message, in the same channel.
edit messageReplaces the components of a message the bot sent.
message sent by the botThe message that was just sent. Use it right after a send or reply block.

Both take a components input. See Components for what goes in it.

Messages only ping users unless you change it with the gear on the block. See Allowing pings.

info

A bot can only edit its own messages. Discord does not allow anything else.

Deleting​

Delete message

delete message removes it. The bot needs the Manage Messages permission unless the message is its own.

To clear a lot at once, use delete the last ... messages on channel from Channels.

Pinning​

BlockWhat it does
pinPins the message.
unpinUnpins it.

A channel can hold 50 pinned messages.

Reactions​

React to message

react to message ... with emoji adds a reaction. Use a standard emoji directly, or the name of a custom emoji from the server.

Reading reactions​

Reaction property

get users of reaction ... with emoji gives you a list of everyone who reacted with a specific emoji. The dropdown also offers the count.

For each reaction

for each reaction in ... loops over every reaction on the message. Inside the loop:

BlockReturns
reaction emojiThe emoji of the current reaction.
reaction countHow many people used it.
reaction usersThe members who used it.

For the event that fires the moment somebody reacts, see Message Actions.

A worked example: a starboard​

  1. when a reaction is added to a message from Message Actions.
  2. Check the emoji is ⭐ and the count is at least 3.
  3. Build a message with a container, the original text, and a link back.
  4. send message in channel into your starboard channel.
  5. Store the original message ID in a database so you never post the same message twice.