
What changed
Until now, your commands only worked inside a server. With DM Commands, members can open a DM with your bot and run the same slash, User and Message commands there. Nothing changes for commands you already have: they stay Servers only until you switch them.
Turn it on for a command
- Open the command in the Command Builder.
- Under the command type, find Where it can be used and click Change.
- Pick Servers and the bot's DMs, then save.
Do something different in a DM
The new {command_context} variable is server or dm. Check it in an If / Else block and send each place down its own path.
{command_context} equals dmPoint blocks at a server you share
There is no server in a DM. Some blocks, such as Add Roles, Create a Channel and Set Variable, have a Server ID field: put {mutual_server_id} there to use a server the member and your bot are both in. If your bot can't find one, it's empty. Kick, ban and timeout can't be used in a DM.
{command_context}server or dm, depending on where the command was run{mutual_server_id}The ID of a server the member shares with your bot, or empty if none is foundHide commands from members without permission
Also new: turn on Hide from members without the required permissions in a command's Permissions panel, and Discord hides the command from members who don't have its required permissions. Your command list stays short for everyone else.
Good to know
- Existing commands are unchanged and stay Servers only until you switch them.
- In a DM, blocks that need a server (roles, channels, kick, ban, timeout, and changing per-server variables) go to the command's error handler. Replies, buttons, forms, conditions and API requests all work.
- Variables work in a DM when Separate values in each server is turned off for them. If it is on, they read as their default value.
- Members can DM your bot when they share a server with it. Role and channel rules and required permissions only apply inside servers; users banned from a command are still blocked in DMs.
Full list of changes
- NewDM Commands: members can run your slash, User and Message commands in a DM with your bot, turned on per command under Where it can be used
- New
{command_context}variable, server or dm, so a command can do something different in a DM - New
{mutual_server_id}variable: a server the member shares with your bot, for blocks that need a server in a DM - NewHide from members without the required permissions in a command's Permissions panel, so Discord hides the command from members who don't have its required permissions
- ImprovedNew Allowed roles, Banned roles and Banned channels pickers in the Command Builder: pick a server, search, tick or paste an ID
- ImprovedSearchable Required permissions picker in the Command Builder, grouped like Discord's role settings with plain names such as Ban Members and a Done button
- ImprovedThe Permissions section in the Command Builder is now one compact panel, with a summary chip showing whether the command is open to everyone
- ImprovedNew commands show up in Discord straight away without refreshing for bots made since 21 September in up to 10 servers; commands that also work in DMs still need a refresh
- ImprovedNew floating Unsaved changes bar whose Save Changes button shows saving, Saved! and Try again right in the button