Additional Features

Here's all the list of additional features in commands. We recommend that you also take a look at the documentationopen in new window.

Command Respond/Edit

const { Command, MessageActionRow } = require("gcommands");
const { MessageEmbed } = require("discord.js");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
    });
  }

  async run({ respond, edit }) {
    respond({
      content: "I'm too lazy to make an actual ping command", // content accepts string, number, MessageEmbed
      ephemeral: true, // makes the message only visible for the user
      allowedMentions: {}, // allowedMentions, more here: https://discord.js.org/#/docs/main/stable/typedef/MessageMentionOptions
      embeds: new MessageEmbed()
        .setAuthor("hi")
        .setTitle("TOP TEXT")
        .setDescription("BOTTOM TEXT"),
      components: new MessageActionRow(), // MessageActionRow, [MessageActionRow, MessageActionRow]
      attachments: new MessageAttachment(
        Buffer.from("me when\nme when guide"),
        "funny_meme.txt"
      ), // MessageAttachment, [MessageAttachment, MessageAttachment]
      inlineReply: true, // if set to true, the client will reply to the latest message in the channel
    });

    setTimeout(() => {
      edit({
        content: "Yep, still lazy", // content accepts string, number, MessageEmbed
        embeds: new MessageEmbed()
          .setAuthor("hi")
          .setTitle("TOP TEXT")
          .setDescription("BOTTOM TEXT"),
        components: new MessageActionRow(), // MessageActionRow, [MessageActionRow, MessageActionRow]
      });
    }, 2500);
  }
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

Cooldowns

Spam is one of the things you want your bot to avoid. GCommands has added a cooldown parameter for commands:

const { Command } = require("gcommands");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
      cooldown: "1s", // String | can also be: 1m, 1h, 1d, ...
    });
  }

  async run(/* ... */) {
    // ...
  }
};







 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Categories

Categories can help you find commands more easily. You can either:

  • add the category parameter to your command:
const { Command } = require("gcommands");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
      cooldown: "1s",
      category: "Utilities", // String
    });
  }

  async run(/* ... */) {
    // ...
  }
};








 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  • put your command in a folder:
cmdDir/
  Utilities/
    ping.js

 

1
2
3

WARNING

Keep in mind, categories are case sensitive!

Aliases

Aliases can help users find your command more easily, or just save them a few words. More about Aliases in Slash Commandsopen in new window

const { Command } = require("gcommands");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
      aliases: ["pong", "pingpong"],
      cooldown: "1s",
      category: "Utilities", // String
    });
  }

  async run(/* ... */) {
    // ...
  }
};









 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

UserPermissions

GCommands has also added a userRequiredPermissions key to commands, so you can save a few lines of, checking for permissions.

const { Command } = require("gcommands");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
      aliases: ["pong", "pingpong"],
      cooldown: "1s",
      category: "Utilities",
      userRequiredPermissions: "ADMINISTRATOR", // Permission, [Permission, Permission]
    });
  }

  async run(/* ... */) {
    // ...
  }
};










 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

ClientRequiredPermissions

Along with userRequiredPermissions, GCommands has also added a clientRequiredPermissions key, to check if your client has a specific permissions

const { Command } = require("gcommands");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
      aliases: ["pong", "pingpong"],
      cooldown: "1s",
      category: "Utilities",
      userRequiredPermissions: "ADMINISTRATOR",
      clientRequiredPermissions: "ADMINISTRATOR", // Permission, [Permission, Permission]
    });
  }

  async run(/* ... */) {
    // ...
  }
};











 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

UserRequiredRoles

The userRequiredRoles property only allows members who have a specific role to run the command

const { Command } = require("gcommands");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
      aliases: ["pong", "pingpong"],
      cooldown: "1s",
      category: "Utilities",
      userRequiredPermissions: "ADMINISTRATOR",
      clientRequiredPermissions: "ADMINISTRATOR",
      userRequiredRoles: ["69", "420"], // [Snowflake, Snowflake]
    });
  }

  async run(/* ... */) {
    // ...
  }
};












 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

GuildOnly

This property makes the command only create/work on a specific guildId. This is recommended for server-specific bots, or just for testing.

const { Command } = require("gcommands");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
      aliases: ["pong", "pingpong"],
      cooldown: "1s",
      category: "Utilities",
      userRequiredPermissions: "ADMINISTRATOR",
      clientRequiredPermissions: "ADMINISTRATOR",
      userRequiredRoles: ["69", "420"],
      guildOnly: "123", // Snowflake
    });
  }

  async run(/* ... */) {
    // ...
  }
};













 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

UserOnly

This property only allows a specific user(s) to run the command.

const { Command } = require("gcommands");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
      aliases: ["pong", "pingpong"],
      cooldown: "1s",
      category: "Utilities",
      userRequiredPermissions: "ADMINISTRATOR",
      clientRequiredPermissions: "ADMINISTRATOR",
      userRequiredRoles: ["69", "420"],
      guildOnly: "123",
      userOnly: "456", // Snowflake, [Snowflake, Snowflake]
    });
  }

  async run(/* ... */) {
    // ...
  }
};














 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

ChannelOnly

This property makes the command only be runnable in a specific channel(s).

const { Command } = require("gcommands");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
      aliases: ["pong", "pingpong"],
      cooldown: "1s",
      category: "Utilities",
      userRequiredPermissions: "ADMINISTRATOR",
      clientRequiredPermissions: "ADMINISTRATOR",
      userRequiredRoles: ["69", "420"],
      guildOnly: "123",
      userOnly: "456",
      channelOnly: "789", // Snowflake, [Snowflake, Snowflake]
    });
  }

  async run(/* ... */) {
    // ...
  }
};















 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

NSFW

This property makes the commad send a hent- This property makes the command only runnable in NSFW channels.

const { Command } = require("gcommands");

module.exports = class extends Command {
  constructor(client) {
    super(client, {
      name: "ping",
      description: "Shows the bot's ping",
      aliases: ["pong", "pingpong"],
      cooldown: "1s",
      category: "Utilities",
      userRequiredPermissions: "ADMINISTRATOR",
      clientRequiredPermissions: "ADMINISTRATOR",
      userRequiredRoles: ["69", "420"],
      guildOnly: "123",
      userOnly: "456",
      channelOnly: "789",
      nsfw: false, // Boolean
    });
  }

  async run(/* ... */) {
    // ...
  }
};
















 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24