disnake icon indicating copy to clipboard operation
disnake copied to clipboard

feature request: more options for command syncing

Open onerandomusername opened this issue 3 years ago • 4 comments

Summary

config class for command sync.

What is the feature request for?

The core library

The Problem

I want to be able to ensure that command sync will not do anything to commands I don't want it to.

The Ideal Solution

It would be nice if the interface for syncing commands was a bit more exposed, and there were some additional options/control over syncing commands. Something like a config class, CommandSync being passed to the bot class to set parameters could be beneficial to be able to fine tune the system.

The Current Solution

Pray a command isn't removed from the bot and then deleted from discord.

Additional Context

No response

onerandomusername avatar Apr 12 '22 00:04 onerandomusername

related issue: #265

shiftinv avatar Apr 16 '22 14:04 shiftinv

My bug report about bots not syncing slash commands added after they are constructed was closed as not intended functionality (which is not at all clear from the documentation!) so I'm going to add on to this feature request that it would be great to have the option to sync slash commands after the bot logs in.

My use case is: on my development computer I have the token for a test bot account in a text file and on my production computer I have the production bot account's token saved. After the bot reads the token and logs in, it is able to see whether it logged in to the production or to the test account. Then, it can create the appropriate slash commands in the appropriate guilds - in the test environment, it can have slash commands for debug screens and menus, and it is targeting only a specific local test guild. This is the most foolproof system I've come up with for isolating the test and production functionality - the single source of truth for whether or not to open debug mode is the actual account that the bot is logged in to.

For now, I will putter around using Client.add_guild_command and Client.add_global_command, which seem to be the least bad solution for registering slash commands when you want to in case anyone else is looking for one, but it would be great to have automatic slash command syncing at other times than in the constructor, and please, document alongside the slash_command decorator and/or the add_slash_command method that command synchronization is currently initiated upon bot construction only, no matter what you set auto_sync to; it is currently in no way clear that synchronization only occurs once in the bot's life cycle (IMO, auto_sync as an argument name implies the opposite.)

toBeOfUse avatar Jul 10 '22 21:07 toBeOfUse

The documentation on this definitely needs work.

As for your specific use-case, it would probably be best to have separate cogs for the production and development sides of your bot. You can then load the cogs accordingly based on the token you passed to the bot. Another positive for this approach is that re/un/loading cogs automatically re-syncs your commands to the current state.

This is also why the name auto_sync holds water, as commands are actually auto_synced as cogs are added/removed to the bot. Note that, for the most part, cogs are currently the go-to way of managing both organization and modularity of code. In case you are not familiar with cogs, you can read up on them in our guide.

If you have further questions or want to discuss anything, feel free to get in touch with us on the support server.

Sharp-Eyes avatar Jul 10 '22 21:07 Sharp-Eyes

Thank you for this, your replies are very helpful

toBeOfUse avatar Jul 10 '22 22:07 toBeOfUse