📕
AFKHandler
  • Introduction
  • FAQ
  • Changelog
  • Classes
    • AFKHandler
    • Command
    • SlashCommand
    • Event
    • Feature
  • Methods
    • Commands
    • SlashCommands
    • deleteSlash
    • Events
    • Features
    • load
    • setCooldown
    • time
    • convert
    • convertLong
  • Types
  • AFKHandlerInteraface
  • AFKHandlerOptions
  • CommandInterface
  • SlashCommandInterface
  • EventInterface
  • FeatureInterface
  • CommandHelp
  • (Callbacks)
  • (Utils)
Powered by GitBook
On this page

Was this helpful?

  1. Classes

SlashCommand

PreviousCommandNextEvent

Last updated 3 years ago

Was this helpful?

class SlashCommand<T = unknown> implements <T>

constructor(options: <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
  },
});
import { SlashCommand } from "afkhandler";

export default 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
  },
});

SlashCommandInterface
SlashCommandInterface