pythondiscordpycord

Pycord Slash commands, How do you set guild_ids too all guilds bot is in


In Pycord when creating a slash command you need to tell it what servers it can be used in. You do this by adding a argument called guild_ids.

But how would I put a list of guild ids for all the servers my bot is in? I've tried multiple methods but unless I set the guild_ids manually it won't let other servers use them.

It would also have to update every few seconds in case someone invites it too a new server.


Solution

  • There is a thing called "global slash commands". If you check the Pycord docs for the slash command, you'll find that the guild_ids parameter is optional, i.e. you can simply omit the guild_ids parameter. If no guild ids are provided, the command will be created globally and be available on every server the bot is in (provided the bot has been granted the applications.commands scope on invite). Note that it may take up to an hour before a global slash command is synchronized to all servers


    As pointed out by @Ice Wolfy in the comments, the one hour wait time was removed by Discord a while ago. Global slash commands now are available near instantly