Skip to content

[Feature] GetActiveThreadsAsync() performance #3149

@marens101

Description

@marens101

GetActiveThreadsAsync() is extremely slow in guilds with a lot of active threads due to how it fetches all threads in a guild and filters locally. This is the only officially documented way (to my knowledge) so is an understandable approach, however there are 2 route missing from Discord's main API documentation that would provide a significant performance boost.

Alternative: /channels/{channelId}/threads/active
Seems to behave the same as the current /guilds/{guildId}/threads/active, but only returns threads under the given parent channel. In my testing this provided a very significant performance boost (~10sec down to ~1sec to fetch threads for an active forum)

Bonus: /channels/{channelId}/threads/search
This one is documented in the API spec, just not the written documentation. It offers additional filtering such as min/max snowflake id, tags, limits etc which would be extremely useful to have available for large servers.
Relevant part of the spec: https://github.com/discord/discord-api-spec/blob/c020f56f103767169d22e12d60f57c810ab98a8a/specs/openapi.json#L3348

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions