Denizen Script Commands


Commands are always written with a '-' before them, and are the core component of any script, the primary way to cause things to happen.
Learn about how commands work in The Beginner's Guide.


Showing 1 out of 167 commands...
Namediscordcommand
Related Guide Pagehttps://guide.denizenscript.com/guides/expanding/ddiscordbot.html
Syntaxdiscordcommand [id:<id>] [create/perms/delete] (group:<group>) (name:<name>) (description:<description>) (options:<options>) (enabled:{true}/false) (enable_for:<list>) (disable_for:<list>)
Short DescriptionManages Discord slash commands.
Full DescriptionManages Discord slash commands.

You can manage slash commands using the "command" instruction, specifying further instructions.

Using the "command" instruction, you can create a new slash command, or edit the permissions of or delete an existing command.

To create (or delete) a command in a specific Discord guild, use the "group" argument. If not present, a global command will be created. NOTE: Global slash commands take up to an hour to register.
When creating, both a name and description are required.

The "options" argument controls the command parameters. It is a MapTag of ordered MapTags that can sometimes hold ordered MapTags. It is recommended to use Command:definemap or a data script key when creating commands.
All option MapTags must have "type", "name", and "description" keys, with an optional "required" key (defaulting to true). The "type" key can be one of: STRING, INTEGER, BOOLEAN, USER, CHANNEL, ROLE, MENTIONABLE.
Additionally, the option map can include a "choices" key, which is a MapTag of ordered MapTags that have a "name" (what displays to the user) and a "value" (what gets passed to the client).

You can use the "enabled" argument to set whether the command should be enabled for everyone by default.
To edit the permissions of a command (who can use it, and who can't), use the "perms" instruction. Permissions MUST be edited AFTER creation.
Use the "enable_for" and "disable_for" arguments (ListTags of DiscordUserTags or DiscordRoleTags - note: actual objects not raw IDs) when editing permissions.

You DO NOT need to create a command on startup every time! Once a command is created, it will persist until you delete it.
Using the "create" instruction on an existing command will update it.

Slash commands and replies to interactions, have limitations. See URL:https://gist.github.com/MinnDevelopment/b883b078fdb69d0e568249cc8bf37fe9.

See also Discord's internal API documentation for commands: URL:https://discord.com/developers/docs/interactions/application-commands

Generally used alongside Command:discordinteraction

The command should usually be ~waited for. See Language:~waitable.
Related Tags<entry[saveName].command> returns the DiscordCommandTag of a slash command upon creation, when the command is ~waited for.
Usage Example
#Use to create a simple slash command without options, which is disabled by default, and save it.
- ~discordcommand id:mybot create group:<discord[mybot].group[Denizen]> name:hello "description:Hello world!" enabled:false save:mycmd
- debug log <entry[mycmd].command.name>
Usage Example
#Use to create a global slash command with one option, using definemap.
- definemap options:
    1:
      type: string
      name: animal
      description: Your favorite animal
      required: true
- ~discordcommand id:mybot create name:animal "description:Pick your favorite!" options:<[options]>
Usage Example
#Use to edit the permissions of a command.
- ~discordcommand id:mybot perms name:mycmd group:<discord[mybot].group[mygroup]> disable_for:<discord[mybot].group[mygroup].role[Muted]> enabled:true
Groupexternal
RequiresdDiscordBot
Sourcehttps://github.com/DenizenScript/dDiscordBot/blob/master/src/main/java/com/denizenscript/ddiscordbot/commands/DiscordCommandCommand.java#L41