Creating a Commands

This is the basic structure of a command.

ping.js
const Discord = require("discord.js");
module.exports = {
  name: "ping",
  aliases: ["pong"],
  execute({ bot, message, args, hkandler }) {
    let pingEmbed = new Discord.MessageEmbed()
      .setColor("RANDOM")
      .setTitle("Pong!")
      .setDescription(`API Latency: ${bot.ws.ping}ms!`);
    message.channel.send(pingEmbed);
  },
};

You can use execute, run, or callback in your command with the default message event

With the default message event, the following properties can be used:

  • Aliases => other names that the command can be called with

  • clientPerms => the permission(s) that the bot will need when running a command

  • userPerms => the permission(s) that the user will need when running a command

  • minArgs => the minimum amount of arguments

  • maxArgs => the maximum amount of arguments

  • ownerOnly => set it so only bot owners can use the command

  • cooldown => number of seconds between each command use per user

Last updated