Search Server Messages

LoopMessages

Search a server's messages and iterate over the matched messages.

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

Inputs

Server IDRequired

ID of the server to search in.

Search ContentRequired

Text to search for in message content.

Example: hello world

Channel IDs

Optional comma-separated channel IDs to restrict the search to.

Author IDs

Optional comma-separated author user IDs to restrict the search to.

Mention IDs

Optional comma-separated user IDs that must be mentioned.

Has Filters

Optional comma-separated has filters, such as attachment, sound, or poll.

Minimum Message ID

Only include messages newer than this message ID.

Maximum Message ID

Only include messages older than this message ID.

Mention Everyone

Filter by whether matched messages mention @everyone or @here.

OptionsAnytruefalse
Sort By

How the search results should be sorted.

Optionsrelevancetimestamp
Sort Order

Whether results should be sorted ascending or descending.

Optionsdescasc
Offset

Pagination offset to start from (0-5000).

Example: 0

Limit

Maximum matched messages to return (1-25, default 25).

Example: 25

Loop Body

Blocks to run for each matched message.

Holds blocks

Outputs

Iteration Number

Current iteration (1-based).

Example: 1

Total Iterations

Total matched messages returned in this page.

Example: 25

Total Results

Total number of matched messages reported by Discord.

Example: 240

Analytics ID

Opaque analytics identifier returned by Discord for this search.

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 Search Server 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: search_discord_guild_messages
  • Loop block: write for item := range search_discord_guild_messages(Args{...}) { ... } and read the current item's outputs from item. See loops.

Inputs

FieldInventScript nameValue
Server IDserver_id
Search Contentsearch_contente.g. "hello world"
Channel IDschannel_ids
Author IDsauthor_ids
Mention IDsmention_ids
Has Filtershas_filters
Minimum Message IDmin_message_id
Maximum Message IDmax_message_id
Mention Everyonemention_everyone"Any", "true", "false"
Sort Bysort_by"relevance", "timestamp"
Sort Ordersort_order"desc", "asc"
Offsetoffsete.g. "0"
Limitlimite.g. "25"
Loop Bodybodyblocks: func() { ... }

Outputs

FieldInventScript nameValue
Iteration Numberiteration_numbere.g. "1"
Total Iterationstotal_iterationse.g. "25"
Total Resultstotal_resultse.g. "240"
Analytics IDanalytics_id
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 searchGuildMessage := range search_discord_guild_messages(Args{server_id: trigger.server_id, search_content: "hello world"}) {
	send_text_message(Args{
		channel_id:      trigger.channel_id,
		message_content: "Total Results: " + searchGuildMessage.total_results,
	})
}

More messages blocks