Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork315
Registering commands in the GuildAvailable event doesn't seem to work#1632
-
I'm attempting to register commands in the I'm using the IReadOnlyDictionary<int,SlashCommandsExtension>slashCommands=awaitDiscordClient.UseSlashCommandsAsync(SlashCommandsConfiguration);slashCommands.RegisterCommands<TestSlashCommandModule>(<redacted>); This however, will not register it: //...IReadOnlyDictionary<int,SlashCommandsExtension>slashCommands=awaitDiscordClient.UseSlashCommandsAsync(SlashCommandsConfiguration);DiscordClient.GuildAvailable+=(sender,args)=>DiscordClient_GuildAvailable(sender,args,slashCommands);//...privateasyncTaskDiscordClient_GuildAvailable(DiscordClientsender,GuildCreateEventArgsargs,IReadOnlyDictionary<int,SlashCommandsExtension>slashCommands){slashCommands.RegisterCommands<TestCommandModule>(args.Guild.Id);} My best guess is this relates to this somewhat vague paragraph in thehelp documentation:
The "at runtime" thing seems a bit odd; surely the app is running the whole time, but you'd need to register commands at some point? Perhaps it refers to the I don't need to dynamically change the commands while the bot is running, but I would like to set non-global slash commands on startup. What am I missing? |
BetaWas this translation helpful?Give feedback.
All reactions
You have to register your commands before connecting to the gateway. Like you said beforeConnectAsync. If you want to lock your commands to one specific guild, you should save the id in your config or hardcode it. If you want to register them for all guild then simply dont provide a id and they will be registered globally
Replies: 1 comment 5 replies
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
You have to register your commands before connecting to the gateway. Like you said before |
BetaWas this translation helpful?Give feedback.
All reactions
-
Ah, darn, that is unfortunate. I'm guessing this is an implementation detail specific to DSharpPlus, as Discord.NET didn't seem to have this limitation? |
BetaWas this translation helpful?Give feedback.
All reactions
-
it is an impl detail, but fwiw you can register your commands later and then refresh them |
BetaWas this translation helpful?Give feedback.
All reactions
-
Ah, how does one go about refreshing slash commands if they've been registered later, other than by restarting the bot? |
BetaWas this translation helpful?Give feedback.
All reactions
-
calling the refresh function on the extension |
BetaWas this translation helpful?Give feedback.
All reactions
-
Sorry for the delayed response. Thanks for your responses, cheers! |
BetaWas this translation helpful?Give feedback.