Skip to content

discordCommandManager

javis86 edited this page Sep 14, 2024 · 3 revisions

Introduction

The discorCommandMananger node lets you to create, to update and to delete global application commands and guild application commands.

Inputs

These are all the inputs this node takes. Below are specifc examples for use cases which also shows what variables are required for that action.

Input Type Options Description
msg.action String set, get, delete, deleteAll The action you wish to perform.
msg.command Object command json The string with the command that you need to create or update (By default, the action 'set' acts like an upsert)
msg.guild or msg.guildId String or number guild Id or NULL The Guild ID where the action is performed, if guild is null or empty, the action is performed over global application command context
msg.commandId String or number command Id It´s Used with the actions set or delete

Examples

All examples are supported by a function node that defines the inputs for discordCommandManager node

Creating a command

msg.action = "set";
msg.command =  {
    name: "blop",
    description: "Replies with blop!"
};

return msg;

Creating a command with options

msg.action = "set";
msg.commands =  {
    "name": "blep",
    "type": 1,
    "description": "Send a random adorable animal photo",
    "options": [
        {
            "name": "animal",
            "description": "The type of animal",
            "type": 3,
            "required": true,
            "choices": [
                {
                    "name": "Dog",
                    "value": "animal_dog"
                },
                {
                    "name": "Cat",
                    "value": "animal_cat"
                },
                {
                    "name": "Penguin",
                    "value": "animal_penguin"
                }
            ]
        },
        {
            "name": "only_smol",
            "description": "Whether to show only baby animals",
            "type": 5,
            "required": false
        }
    ]
}

return msg;

Creating a command with autocomplete

msg.action = "set";
msg.commands =  {
    "name": "echo3",
    "description": "Search discordjs.guide!",
    "options": [
      {
        "name": "query",
        "description": "Phrase to search for",
        "type": 3, // Represents STRING input
        "autocomplete": true
      }
    ]
  };

return msg;

Creating a command type MESSAGE

A UI-based command that shows up when you right click or tap on a message Application command types

msg.action = "set";
msg.commands = {
    "name": "Bookmark",
    "type": 3 
};

return msg;

Delete a command from a guild

msg.action = "delete";
msg.commandId = "<< command_id >>";
msg.guildId = "<< guildId >>";
return msg;

Delete all commands from a guild

msg.action = "deleteAll";
msg.guildId = "<< guildId >>";
return msg;

Get all commands from a guild

msg.action = "get";
msg.guildId = "<< guildId >>";
return msg;

Resources

Clone this wiki locally