NewCommand BuilderFree

Introducing DM Commands

Members can now run your commands by messaging your bot directly, and you choose what happens differently in a DM.

BotGhost team2 min read
Ghost Café BotAPP
mmika used /balance
Ghost Café BotAPPToday at 21:04
Your coins
Balance
1,250
Streak
6 days
Coins follow you to every server
A /balance command answering in a DM.

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

  1. Open the command in the Command Builder.
  2. Under the command type, find Where it can be used and click Change.
  3. Pick Servers and the bot's DMs, then save.
Where it can be used
Members can also run this command by messaging the bot directly.
Servers onlyServers and the bot's DMs

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.

Slash Command
/balance
If / Else
{command_context} equals dm
dm
Reply with the member's coins
Else
Reply in the channel as before

Point 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 found

Hide 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
See 22 Sep in the changelog