Skip to main content
Version: Next

RESTGetAPIGuildMessagesSearchQuery

Returns a list of messages without the reactions key that match a search query in the guild. Requires the READ_MESSAGE_HISTORY permission.

@remarks

The Search Guild Messages endpoint is restricted according to whether the MESSAGE_CONTENT Privileged Intent is enabled for your application.

If the entity you are searching is not yet indexed, the endpoint will return a 202 accepted response. The response body will not contain any search results, and will look similar to an error response:

{
"message": "Index not yet available. Try again later",
"code": 110000,
"documents_indexed": 0,
"retry_after": 2
}

Due to speed optimizations, search may return slightly fewer results than the limit specified when messages have not been accessed for a long time. Clients should not rely on the length of the messages array to paginate results.

Additionally, when messages are actively being created or deleted, the total_results field may not be accurate.

@see

Index

Properties

optionalattachment_extension

attachment_extension?: string[]

Filter messages by attachment extension (e.g. txt) (max 256 characters, max 100)

optionalattachment_filename

attachment_filename?: string[]

Filter messages by attachment filename (max 1024 characters, max 100)

optionalauthor_id

author_id?: string[]

Filter messages by these authors (max 100)

optionalauthor_type

author_type?: MessageSearchAuthorType[]

Filter messages by author type

@remarks

All types can be negated by prefixing them with -, which means results will not include messages that match the type.

@see

optionalchannel_id

channel_id?: string[]

Filter messages by these channels (max 500)

optionalcontent

content?: string

Filter messages by content (max 1024 characters)

optionalembed_provider

embed_provider?: string[]

Filter messages by embed provider (case-sensitive, e.g. Tenor) (max 256 characters, max 100)

optionalembed_type

embed_type?: MessageSearchEmbedType[]

optionalhas

Filter messages by whether or not they have specific things

@remarks

All types can be negated by prefixing them with -, which means results will not include messages that match the type.

@see

optionalinclude_nsfw

include_nsfw?: boolean

Whether to include results from age-restricted channels

@defaultValue

false

optionallimit

limit?: number

Max number of messages to return (1-25)

@defaultValue

25

optionallink_hostname

link_hostname?: string[]

Filter messages by link hostname (e.g. discordapp.com) (max 256 characters, max 100)

optionalmax_id

max_id?: string

Get messages before this message ID

optionalmention_everyone

mention_everyone?: boolean

Filter messages that do or do not mention

@everyone

optionalmentions

mentions?: string[]

Filter messages that mention these users (max 100)

optionalmentions_role_id

mentions_role_id?: string[]

Filter messages that mention these roles (max 100)

optionalmin_id

min_id?: string

Get messages after this message ID

optionaloffset

offset?: number

Number to offset the returned messages by (max 9975)

optionalpinned

pinned?: boolean

Filter messages by whether they are or are not pinned

optionalreplied_to_message_id

replied_to_message_id?: string[]

Filter messages that reply to these messages (max 100)

optionalreplied_to_user_id

replied_to_user_id?: string[]

Filter messages that reply to these users (max 100)

optionalslop

slop?: number

Max number of words to skip between matching tokens in the search content (max 100)

@defaultValue

2

optionalsort_by

The sorting algorithm to use

@remarks

Sort order is not respected when sorting by relevance.

@see

optionalsort_order

sort_order?: asc | desc

The direction to sort (asc or desc)

@defaultValue

'desc'

@remarks

Sort order is not respected when sorting by relevance.