Skip to Content
BuildcordDocs

Search messages

Find messages in the server with Discord's own search.

server.search searches the server's messages the way Discord's search bar does, and hands back what it finds as a list.

Settings

SettingWhat it does
WordsWhat to search for, such as {option.query}.
In channelsOnly these channels or threads: ids or mentions, separated by commas. Empty is every channel.
Never inChannels to leave out, along with the threads in them. The channel the flow was used in is still searched.
FromOnly messages by these members.
Mentioning, Mentioning rolesOnly messages that mention these members, or roles.
Mentions @everyoneOnly messages that do, or only those that don't.
Replying to members, Replying to messagesOnly replies to these members, or to these messages by id.
HasAny of image, sound, video, file, sticker, embed, link, poll and snapshot. Put - in front to leave those out, such as -link.
Written byuser, bot or webhook. Put - in front to leave those out, such as -bot.
PinnedOnly pinned messages, or only those that aren't.
After message, Before messageOnly messages after, or before, this one.
Sorted byNewest first, oldest first, or most relevant.
DirectionAscending or descending, overriding the one the sort gives, such as most relevant last.
Bring backHow many, up to 25.
Skip the firstFor the next page: skip as many as were brought back before.
Only channels they can readOn by default. Searches only where the member who set the flow off can read the history.
Include age-restricted channelsOff by default.
Links to, Files ending in, Files namedOnly messages linking to these hostnames, or with these files.
Embeds of kind, Embeds fromOnly messages with these kinds of embed, or embeds from these providers, such as YouTube.
Words betweenHow many words may come between the words searched for.

Ways out

Way outWhen
foundSomething matched.
noneNothing did.

Tokens

TokenValue
{search.results}The messages found, as a list. Each has id, channel, channelMention, link, content, at, pinned, files, embeds, replyTo and author (id, name, mention, bot, avatar).
{search.count}How many came back
{search.total}How many match in all
{search.skipped}Channels named in In channels that Never in left out

Go through the results with For each item and {loop.item.content}, or turn them into a message in Run code.

Notes

  • The bot needs Read Message History in the channels it searches.
  • Discord takes a moment to index a server the first time it's searched. The step waits up to eight seconds, then fails.

Was this page helpful?