Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.8k stars 2.3k forks source link

Add methods for getting app command IDs/mentions from cache #6278

Open Flame442 opened 10 months ago

Flame442 commented 10 months ago

Description of the changes

Adds bot.get_app_command_id and bot.get_app_command_mention which pull from the ID cache built when RedTree.syncing.

Potential future work:

Fixes #5976

Have the changes in this PR been tested?

Yes

Jackenmen commented 10 months ago

Potential future work:

  • Migrate the current data structure to allow caching on guild sync, and allow these new methods to be used to pull from that cache as well

Having such a cache now would mean we don't need to make these methods asynchronous and such a change to method signature is not really something we can do once the API is released. Is there any reason we wouldn't want those methods to be synchronous?

Flame442 commented 10 months ago

I don't mean a memory cache, I mean storing in config guild specific command ids. Currently, only global app command ids are stored, since that is all the [p]slash system cares about. (Edited original to be more clear)

Jackenmen commented 10 months ago

Oh yeah, I missed that this remark is about guild stuff. Either way, I am still wondering about the in-memory cache thing to get a synchronous API, it does seem a bit unfortunate that it requires awaiting right now.