CDHandler
  • CDHandler Documentation
  • Links
    • NPM Page
    • GitHub Repository
    • Example Bots using CDHandler
    • Discord Server
  • Development
    • Changelog
    • Contribute
    • Issues and Feature Requests
  • Using CDHandler
    • Installation
    • Main File
    • Commands
      • Examples
      • Slash Commands
    • Intellisense
    • Events
    • Features
    • Prefixes
  • Other Packages
    • CDGen
    • CDColours
    • CDCommands
Powered by GitBook
On this page

Was this helpful?

  1. Using CDHandler
  2. Commands

Examples

Below is an example command in JavaScript, TypeScript and CoffeeScript

// File Name - ping.js

const { MessageEmbed } = require("discord.js");

module.exports = {
  name: "ping",
  aliases: ["Pong"],
  description: "Replies with Pong!",
  cooldown: "5s",
  cooldownMessage: "Wait {REMAINING} more to execute this command again!",
  //usage: "", it's not needed on this command
  //example: "", it's not needed on this command
  minArgs: 0,
  maxArgs: 0,
  argsMessage:
    "Incorrect Arguments! There are no arguments required for this command!",
  dev: true,
  devMessage: "You must be a developer to run this command!",
  nsfw: true,
  nsfwMessage: "You cannot run this command in SFW channels!",
  permissions: ["KICK_MEMBERS"],
  permissionsMessage:
    "You must have the 'Kick Members' permission to run this command!",
  botPermissions: ["EMBED_LINKS"],
  botPermissionsMessage:
    "I cannot run this command without the 'Embed Links' permission!",
  category: "Misc",
  locked: true,
  lockedMessage: "This command is locked at the moment!",
  hidden: true,
  hidden2: true,
  servers: ["769710808435261490"],
  serversMessage: "Use this command in CDHandler support server!",
  run: ({ message, args, client, handler }) => {
    /* handler represents CDHandler but don't change the param name you can use callback, execute or fire instead of run */
    const embed = new MessageEmbed().setColor("#00DCFF").setTitle("Pong!");

    message.channel.send(embed);

    handler.cooldown(message, "5s"); // this creates a cooldown
  },
};
// File Name - ping.ts

import { MessageEmbed } from "discord.js";

export default {
  name: "ping",
  aliases: ["Pong"],
  description: "Replies with Pong!",
  cooldown: "5s",
  cooldownMessage: "Wait {REMAINING} more to execute this command again!",
  //usage: "", it's not needed on this command
  //example: "", it's not needed on this command
  minArgs: 0,
  maxArgs: 0,
  argsMessage:
    "Incorrect Arguments! There are no arguments required for this command!",
  dev: true,
  devMessage: "You must be a developer to run this command!",
  nsfw: true,
  nsfwMessage: "You cannot run this command in SFW channels!",
  permissions: ["KICK_MEMBERS"],
  permissionsMessage:
    "You must have the 'Kick Members' permission to run this command!",
  botPermissions: ["EMBED_LINKS"],
  botPermissionsMessage:
    "I cannot run this command without the 'Embed Links' permission!",
  category: "Misc",
  locked: true,
  lockedMessage: "This command is locked at the moment!",
  hidden: true,
  hidden2: true,
  servers: ["769710808435261490"],
  serversMessage: "Use this command in CDHandler support server!",
  run: ({ message, args, client, handler }: any) => {
    /* handler represents CDHandler but don't change the param name
     you can use callback, execute or fire instead of run */
    const embed = new MessageEmbed().setColor("#00DCFF").setTitle("Pong!");

    message.channel.send(embed);

    handler.cooldown(message, "5s"); // this creates a cooldown
  },
};// File Name - ping.ts
# File Name - ping.coffee

{ MessageEmbed } = require("discord.js");

module.exports = {
  name: "ping"
  aliases: ["Pong"]
  description: "Replies with Pong!"
  cooldown: "5s"
  cooldownMessage: "Wait {REMAINING} more to execute this command again!"
  # usage: "", it's not needed on this command
  # example: "", it's not needed on this command
  minArgs: 0
  maxArgs: 0
  argsMessage:
    "Incorrect Arguments! There are no arguments required for this command!"
  dev: true
  devMessage: "You must be a developer to run this command!"
  nsfw: true
  nsfwMessage: "You cannot run this command in SFW channels!"
  permissions: ["KICK_MEMBERS"]
  permissionsMessage:
    "You must have the 'Kick Members' permission to run this command!"
  botPermissions: ["EMBED_LINKS"]
  botPermissionsMessage:
    "I cannot run this command without the 'Embed Links' permission!"
  category: "Misc"
  locked: true
  lockedMessage: "This command is locked at the moment!"
  hidden: true
  hidden2: true
  servers: ["769710808435261490"]
  serversMessage: "Use this command in CDHandler support server!"
  run: ({ message, args, client, handler }) -> 
    # handler represents CDHandler but don't change the param name you can use callback, execute or fire instead of run 
    embed = new MessageEmbed().setColor("#00DCFF").setTitle("Pong!");

    message.channel.send embed

    handler.cooldown(message, "5s"); # this creates a cooldown
  
};
PreviousCommandsNextSlash Commands

Last updated 4 years ago

Was this helpful?