Get Messages

LoopMessages

Fetch recent messages from a channel and iterate over them.

  • Loop block: the blocks placed inside it run once for each item, and can use the current item's outputs.

Inputs

Channel IDRequired

ID of the channel to fetch messages from.

LimitRequired

Number of messages to fetch (max 100).

Example: 50

Before Message ID

Fetch messages before this message ID.

After Message ID

Fetch messages after this message ID.

Around Message ID

Fetch messages around this message ID.

Loop Body

Blocks to run for each message.

Holds blocks

Outputs

Iteration Number

Current iteration (1-based).

Example: 1

Total Iterations

Total number of messages returned.

Example: 50

Message ID

ID of the message.

Example: 123456789012345678

Channel ID

ID of the channel containing the message.

Example: 123456789012345678

Server ID

ID of the server containing the message.

Example: 123456789012345678

Content

Text content of the message.

Author ID

ID of the message author.

Example: 123456789012345678

Author Username

Username of the message author.

Author Global Name

Display name of the message author.

Author Avatar URL

Avatar URL of the message author.

Author Mention

Mention string for the message author.

Example: <@123456789012345678>

Author Is Bot

Whether the message author is a bot.

Example: false

Message Sent At (Unix)

Unix timestamp when the message was sent.

Example: 1640995200

Message Edited At (Unix)

Unix timestamp when the message was last edited. Empty if never edited.

Is Pinned

Whether the message is pinned.

Example: false

Is TTS

Whether the message is text-to-speech.

Example: false

Mention Everyone

Whether the message mentions everyone.

Example: false

User Mentions

Comma-separated IDs of mentioned users.

Example: 123456789012345678,987654321098765432

Role Mentions

Comma-separated IDs of mentioned roles.

Example: 123456789012345678,987654321098765432

Attachment Count

Number of attachments on the message.

Example: 0

Attachment URLs

Comma-separated URLs of message attachments.

Embed Count

Number of embeds on the message.

Example: 0

Reply To Message ID

ID of the message this is replying to. Empty if not a reply.

Webhook ID

Webhook ID if the message was sent by a webhook.

Message Link

Direct link to the message.

Example: https://discord.com/channels/123/456/789

Thread ID

ID of the thread started from this message. Empty if none.

Sticker IDs

Comma-separated IDs of stickers on the message.

Embed Title

Title of the first embed. For Components v2 messages, the leading "## " heading in the first container.

Embed Description

Description of the first embed. For Components v2 messages, the first plain text in the first container.

Embed URL

URL of the first embed.

Embed Color

Color of the first embed as a decimal integer. For Components v2 messages, the first container's accent color.

Example: 3447003

Embed Image URL

Image URL of the first embed. For Components v2 messages, the first gallery image in the first container.

Embed Thumbnail URL

Thumbnail URL of the first embed. For Components v2 messages, the first section thumbnail in the first container.

Embed Footer Text

Footer text of the first embed. For Components v2 messages, the "-# " subtext in the first container.

Embed Footer Icon URL

Footer icon URL of the first embed.

Embed Author Name

Author name of the first embed.

Embed Author URL

Author URL of the first embed.

Embed Author Icon URL

Author icon URL of the first embed.

Embed Timestamp

Timestamp of the first embed.

Embed Timestamp (Unix)

Unix timestamp of the first embed.

Is Components v2

Whether the message uses Components v2 (sent by Send Advanced Message or Send Embed Message blocks).

Example: false

Text Content

All Components v2 text in the message, including text inside containers and sections, joined by newlines.

Container Accent Color

Accent color of the first Components v2 container as a decimal integer.

Example: 3447003

Media URLs

Comma-separated URLs of Components v2 gallery images and thumbnails.

Build a bot using blocks like Get Messages

Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.

Advanced Documentation

This documentation can be useful when using code mode. View as Markdown

ID: get_discord_channel_messages
  • Loop block: write for item := range get_discord_channel_messages(Args{...}) { ... } and read the current item's outputs from item. See loops.

Inputs

FieldInventScript nameValue
Channel IDchannel_id
Limitlimite.g. "50"
Before Message IDbefore_id
After Message IDafter_id
Around Message IDaround_id
Loop Bodybodyblocks: func() { ... }

Outputs

FieldInventScript nameValue
Iteration Numberiteration_numbere.g. "1"
Total Iterationstotal_iterationse.g. "50"
Message IDmessage_ide.g. "123456789012345678"
Channel IDchannel_ide.g. "123456789012345678"
Server IDserver_ide.g. "123456789012345678"
Contentcontent
Author IDauthor_ide.g. "123456789012345678"
Author Usernameauthor_username
Author Global Nameauthor_global_name
Author Avatar URLauthor_avatar_url
Author Mentionauthor_mentione.g. "<@123456789012345678>"
Author Is Botauthor_is_bote.g. "false"
Message Sent At (Unix)message_sent_ate.g. "1640995200"
Message Edited At (Unix)message_edited_at
Is Pinnedis_pinnede.g. "false"
Is TTSis_ttse.g. "false"
Mention Everyonemention_everyonee.g. "false"
User Mentionsuser_mentionse.g. "123456789012345678,987654321098765432"
Role Mentionsrole_mentionse.g. "123456789012345678,987654321098765432"
Attachment Countattachment_counte.g. "0"
Attachment URLsattachment_urls
Embed Countembed_counte.g. "0"
Reply To Message IDreply_to_message_id
Webhook IDwebhook_id
Message Linkmessage_linke.g. "https://discord.com/channels/123/456/789"
Thread IDthread_id
Sticker IDssticker_ids
Embed Titleembed_title
Embed Descriptionembed_description
Embed URLembed_url
Embed Colorembed_colore.g. "3447003"
Embed Image URLembed_image_url
Embed Thumbnail URLembed_thumbnail_url
Embed Footer Textembed_footer_text
Embed Footer Icon URLembed_footer_icon_url
Embed Author Nameembed_author_name
Embed Author URLembed_author_url
Embed Author Icon URLembed_author_icon_url
Embed Timestampembed_timestamp
Embed Timestamp (Unix)embed_timestamp_unix
Is Components v2is_components_v2e.g. "false"
Text Contenttext_content
Container Accent Colorcontainer_accent_colore.g. "3447003"
Media URLsmedia_urls

Example InventScript

for channelMessage := range get_discord_channel_messages(Args{channel_id: trigger.channel_id, limit: 50}) {
	send_text_message(Args{
		channel_id:      trigger.channel_id,
		message_content: "Message ID: " + channelMessage.message_id,
	})
}

More messages blocks