Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Discord.py app_commands.guilds doesn't work as expected

$
0
0
class PrivateCogs(commands.Cog, name="PrivateFuncs"):    def __init__(self, bot: commands.Bot):        super().__init__()        self.bot = bot        self.logger = logging.getLogger('discord')    @app_commands.command(name="shutdown", description="Shuts down the bot")    @app_commands.guilds(int(os.environ["TEST_SERVER_ID"]))    #@app_commands.default_permissions(administrator=True)    @is_owner()    async def shutdown(self, interaction: discord.Interaction):        await interaction.response.send_message("Shutting down bot", ephemeral=True)        await self.bot.close()        print(f"Bot closed by {interaction.message.author.name}")

Here is my code, and my problem is if I am commenting out the @app_commands.guilds(int(os.environ["TEST_SERVER_ID"])) line it works just fine as a global command. But if I leave it like this it should put it only in my test server, instead the command is not visible when I start typing a / in my discord server so I can't even execute it. And all of my global commands are there and in the server settings/integration I see the global commands that are in a different cog.

I tried to write app_commands.guilds(discord.Object(int(os.environ["TEST_SERVER_ID"]))) but that has the same effect, the command is not available in my server after a sync.When I hard code in my server's id to the decorator for example like this: app_commands.guilds(discord.Object(12345678)) and I sync the commands, the others are fine, but this one just not visible, so I can't execute it. But I don't understand why, because there was an example exactly like this in the discord.py docs.I would like to know what am I doing wrong with this approach, so any help would be appreciated.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>