📕
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

Command

PreviousAFKHandlerNextSlashCommand

Last updated 3 years ago

Was this helpful?

class Command<T = unknown> implements <T>

constructor(options: <T>)

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

module.exports = new Command({
  name: "ping", // command name
  aliases: ["pong"], // command aliases
  help: {
    // help information
    description: "replies!", // description of it
    usage: "<please>", // usage
    example: "please", // example
    note: "You have to say please to make it run!", // additional information
    category: "Fun", // category
  },
  hidden: false, // if it's hidden
  guilds: [], // list of guilds ids where the command is allowed
  guildsMsg: "Sorry, but this isn't the correct guild to execute that command", // when we run the command in a wrong guild
  nsfw: false, // nsfw command,
  nsfwMsg: "this command is nsfw!", // message that appears when a command is nsfw and is executed in q non nsfw channel;
  dev: false, // developer command;
  devMsg: "you aren't a dev!", // message sent when a developer command isn't used by a developer;
  permissions: ["ADD_REACTIONS"], // permissions that a GuildMember requires to execute the command;
  permissionsMsg: "you don't have that permissions", // message sent when a member without any permission setted on permissions property;
  locked: false, // if the command is currently locked;
  lockedMsg: "this command is currently locked", // message sent when a locked command is executed;
  cooldown: "15s", // cooldown
  cooldownMsg: (remaining) =>
    `Please wait ${remaining} more to execute this command again`, 
    // message sent when a user is on cooldown (function where the 1st parameter is the remaining time, returned value is what will be sent)
  args: { max: 1, min: 1 }, // maximum and minimum arguments
  argsMsg: "You didn't say please", // message sent when the user message doesn't satisfy the given arguments;
  botPermissions: ["SEND_MESSAGES"], // permissions that the bot requires to execute a command;
  botPermissionsMsg: "I don't have permissions to send this message", 
  // message sent when the bot doesn't have every permission specified in botPermissions property;
  run({ client, args, message }, gadget) {
    // run can be execute, callback, fire or emit
    message.channel.send("Pong!");
    return true;
    // returning true adds cooldown
  },
});
import { Command } from "afkhandler";

export default new Command({
  name: "ping", // command name
  aliases: ["pong"], // command aliases
  help: {
    // help information
    description: "replies!", // description of it
    usage: "<please>", // usage
    example: "please", // example
    note: "You have to say please to make it run!", // additional information
    category: "Fun", // category
  },
  hidden: false, // if it's hidden
  guilds: [], // list of guilds ids where the command is allowed
  guildsMsg: "Sorry, but this isn't the correct guild to execute that command", // when we run the command in a wrong guild
  nsfw: false, // nsfw command,
  nsfwMsg: "this command is nsfw!", // message that appears when a command is nsfw and is executed in q non nsfw channel;
  dev: false, // developer command;
  devMsg: "you aren't a dev!", // message sent when a developer command isn't used by a developer;
  permissions: ["ADD_REACTIONS"], // permissions that a GuildMember requires to execute the command;
  permissionsMsg: "you don't have that permissions", // message sent when a member without any permission setted on permissions property;
  locked: false, // if the command is currently locked;
  lockedMsg: "this command is currently locked", // message sent when a locked command is executed;
  cooldown: "15s", // cooldown
  cooldownMsg: (remaining) =>
    `Please wait ${remaining} more to execute this command again`, 
    // message sent when a user is on cooldown (function where the 1st parameter is the remaining time, returned value is what will be sent)
  args: { max: 1, min: 1 }, // maximum and minimum arguments
  argsMsg: "You didn't say please", // message sent when the user message doesn't satisfy the given arguments;
  botPermissions: ["SEND_MESSAGES"], // permissions that the bot requires to execute a command;
  botPermissionsMsg: "I don't have permissions to send this message", 
  // message sent when the bot doesn't have every permission specified in botPermissions property;
  run({ client, args, message }, gadget) {
    // run can be execute, callback, fire or emit
    message.channel.send("Pong!");
        return true;
    // returning true adds cooldown
  },
});
CommandInterface
CommandInterface