Add support for server-side message filtering

Author: TyrrrzCreated Mar 31, 2026Updated Mar 31, 2026
Labelsenhancement

Discord has added the search API: https://docs.discord.com/developers/resources/message#search-guild-messages

This should let us leverage our existing message filtering support server-side, vastly reducing export times in some cases.

Proposed implementation:

  1. Keep the existing filtering infrastructure.
  2. When a message filter is specified, use the new guild/{id}/messages/search API instead of the guild/{id}/messages API.
  3. Use the parsed filter to extract individual components like author_id, has, mentions, etc..
  4. Fill out the rest of the query parameters, such that the usage of the messages/search API mimics the messages API as closely as possible (e.g. set channel_id to one specific channel rather than the whole guild).
  5. Get the messages from the API.
  6. Apply our own filtering on top of it.
    • Discord's search feature only supports guild messages, not direct messages.
    • Our filtering functionality may support tokens that Discord itself does not support.
    • Discord's search API has certain limitations (e.g. author_id cannot be used more than 100 times), our filtering functionality does not have limitations.
    • If Discord's search API already successfully filtered the messages, then our own filtering will be a no-op.
    • Otherwise, it will act as a fallback layer, ensuring the messages get filtered locally if not server-side.

Source: Tyrrrz/DiscordChatExporter