Skip to content

By default, commands are registered with ‘dm_permission?’ set to ‘false’ and not null #2034

Description

@Scartzz

Summary

Hello.
When upgrading from the SlashCommands to the Commands Library, I noticed that users can only execute the commands on Guilds and no longer via private message.
After looking at the API Doc and the code for it, there is a deprecated field ‘dm_permission?’ in the Discord API which can be null, false or true.
(https://discord.com/developers/docs/interactions/application-commands)

The default, i.e. if zero is passed, is true and commands are also displayed in DMs.

AllowedContexts should actually be used, but that is not the point.

DSharpPlus.Commands/Processors/MessageCommands
/MessageCommandProcessor.cs

public async Task<DiscordApplicationCommand> ToApplicationCommandAsync(Command command)
    {
        [...]

        return new(
            [...]
            allowDMUsage: command.Attributes.Any(x => x is AllowDMUsageAttribute),
            [...]
        );
    }

In the code of the MessageCommandProcessor, the following is set for allowDMUsage in line 172: command.Attributes.Any(x => x is AllowDMUsageAttribute).

This means that false is set here by default and every command must be explicitly allowed for use in DMs.

I would like to ask if this is intended, that the default is false and not null.

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 Previews

Operating System

Linux Debian

Reproduction Steps

Register a command and try to execute it via DM. If the attribute is not set, it will not be allowed via DM.

Trace Logs

No response

Exceptions or other error messages

No response

Anything else you'd like to share

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    commandsFor issues related to DSharpPlus.Commands

    Type

    Fields

    Effort

    None yet

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions