SlashCommand

class SlashCommand<T = unknown> implements SlashCommandInterface<T>

constructor(options: SlashCommandInterface<T>)

const { SlashCommand } = require("afkhandler");

module.exports = new SlashCommand({
  name: "ping", // Command name
  description: "Replies", // Slash Command description
  help: {
    description: "Replies", // Command description
    usage: "<please>", // Command usage
    example: "please", // Command example
    note: "You have to say please",
    category: "Fun",
  },
  default: true,
  // whether the command is enabled by default when the app is added to a guild
  type: "MESSAGE", // command type
  stop: false,
  // if the handler makes a request to the api publishing this command
  options: [
    {
      type: "STRING", // type
      name: "choose", // name
      description: "choose please", // description
      required: true, // whether it is required
      choices: undefined,
    },
  ],
  cooldown: "10s", // cooldown
  cooldownMsg: (remaining) =>
    `Wait ${remaining} more to execute this command again`,
  // cooldown message
  run({ interaction, user, guild, member }, gadget) {
    // run can be execute, callback, fire or emit
    interaction.reply("Pong!");
        return true;
    // returning true adds cooldown
  },
});

Last updated

Was this helpful?