-
-
Notifications
You must be signed in to change notification settings - Fork 315
Description
Summary
I'm trying to set up a command to only work in DMs:
public class MyQuestionsCommand
{
[Command("myquestions")]
[Description("View your submitted questions.")]
[DirectMessageUsage(usage: DirectMessageUsage.RequireDMs)]
public async Task MyQuestionsAsync(CommandContext context)
{
await context.RespondAsync("todo");
}
}
and adding that in Program.cs
to builder.UseCommands
under extension.AddCommands()
.
Two issues with this (even after restarting bot+client):
- In the bot's DMs, the command does not show up when I type
/
- In any server, the command shows up, when it should not (it does error when someone uses it, but it should not appear in the first place)
Since my bot is open source you can find the code here: https://github.com/Ascyt/open-qotd/tree/28-ability-to-view-personal-questions (Program.cs
is found in root and the command is in /Features/UserCommands/MyQuestions.cs
)
What version of the library are you using?
v5.0.0-nightly (make sure you are using the latest nightly!)
What .NET version are you using? Make sure to use the latest patch release for your major version.
.NET 9.0
Operating System
Windows 11
Reproduction Steps
- Clone https://github.com/Ascyt/open-qotd/tree/28-ability-to-view-personal-questions (make sure it is this branch)
- Set
CUSTOMQOTD_TOKEN
environment variable to your bot token - Start the program
Trace Logs
Output when starting the bot:
[2025-06-01 17:24:34 +00:00] [DSharpPlus.DiscordClient] [Info] DSharpPlus; version 5.0.0-nightly-02516+b53b50c9264f1571474e15804806252094dd5251
Bot started
Started fetch loop
[2025-06-01 17:25:17 +00:00] [DSharpPlus.Commands.Processors.BaseCommandProcessor] [Info] Detected changes in slash command records: 0 without changes, 1 added, 14 edited, 0 deleted
[2025-06-01 17:25:17 +00:00] [DSharpPlus.Commands.Processors.BaseCommandProcessor] [Info] Registered 15 top-level slash commands, 35 total slash commands.
output when not having changed anything and re-running:
[2025-06-01 17:52:22 +00:00] [DSharpPlus.DiscordClient] [Info] DSharpPlus; version 5.0.0-nightly-02516+b53b50c9264f1571474e15804806252094dd5251
[2025-06-01 17:52:22 +00:00] [DSharpPlus.Commands.Processors.BaseCommandProcessor] [Info] No application command changes detected.
[2025-06-01 17:52:22 +00:00] [DSharpPlus.Commands.Processors.BaseCommandProcessor] [Info] Registered 15 top-level slash commands, 35 total slash commands.
Exceptions or other error messages
When run in a guild, it gives the error `ChecksFailedException: Checks for myquestions failed.`, which, as I said it's better to get an error than have it work in guilds (it should not work in guilds), but it'd be better for the command not to show up at all.
Anything else you'd like to share
I have not tried to manually remove the slash commands or create another bot altogether and run the bot again (the first implementation was with an outdated nightly version) - I don't know how to clear those and don't really want to reset the token or have to create a new one.