1.1.8 • Published 5 years ago

@elchologamer/discord-command v1.1.8

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

discord-command

Easily handle commands for your Discord bot using discord.js!

Installation

Run the following command on console:

> npm i discord-command --save

Usage

You can create classes that extend the Command class, and register them on a CommandHandler variable.

Code examples

JavaScript

const Command, { CommandHandler } = require('discord-command');
const { Client } = require('discord.js');

const bot = new Client();

// A command that sends 'Hello world!'
// to the channel when '!hello' is sent
class HelloCommand extends Command {

    constructor() {
        super('hello', 'Says "Hello world!" on the channel', null, false);
    }

    run(event) {
        event.channel.send('Hello world!');
    }

    getHelp() {
        return new MessageEmbed()
            .setTitle('hello command help')
            .setDescription(this.description);
    }
}

// Create CommandHandler with the prefix '!'
const handler = new CommandHandler(bot, '!');
handler.addCommands(new HelloCommand());

console.log('Logging in...');
bot.login(process.env.TOKEN);

TypeScript

import Command, { CommandHandler, CommandEvent } from 'discord-command';
import { Client, MessageEmbed } from 'discord.js';

const bot: Client = new Client();

// A command that sends 'Hello world!'
// to the channel when '!hello' is sent
class HelloCommand extends Command {
  public constructor() {
    super('hello', 'Says "Hello world!" on the channel', null, false);
  }

  public run(event: CommandEvent): void {
    event.channel.send('Hello world!');
  }

  public getHelp(): MessageEmbed {
    return new MessageEmbed()
      .setTitle('hello command help')
      .setDescription(this.description);
  }
}

// Create CommandHandler with the prefix '!'
const handler: CommandHandler = new CommandHandler(bot, '!');
handler.addCommands(new HelloCommand());

console.log('Logging in...');
bot.login(process.env.TOKEN);

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago