1.4.1 • Published 5 years ago

djs-cmds v1.4.1

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

Easy Discord Commands

Simple Discord bot framework.

Installation

npm install djs-cmds

Methods

Create bot instance

const djs-cmds = require("djs-cmds");
const bot = new djs-cmds.Bot();
bot
.setToken("YOUR_DISCORD_BOT_TOKEN")
.setPrefix("!")
.showPrefixOnMention(true)
.connect();

// Now, you can add commands

Add commands

// Simple command
bot.addCommand("test", {
    reply: "You ran test command!"
});

// Complex command
bot.addCommand("say", {
    run: (message, args) => {
        message.delete();
        message.channel.send(args.join(" "));
    },
    aliases: [ "tell" ],
    ownerOnly: true, // or use permissions, like below
    botPermissions: [ "SEND_MESSAGES" ],
    memberPermissions: [ "ADMINISTRATOR" ],
    guildOnly: true // command can only be run on a server
});

Example

const { Bot, BaseCommands } = require("djs-cmds");

const bot = new Bot()
.setToken("YOUR_DISCORD_BOT_TOKEN") // define bot token
.setPrefix("!"); // define bot prefix

// Register a new simple command
bot.addCommand("test", {
    reply: "You ran the test command"
});

// Register a new complex command
bot.addCommand("say", {
    run: (message, args) => {
        message.delete();
        message.channel.send(args.join(" "));
    },
    aliases: [ "tell" ],
    ownerOnly: true, // or use permissions, like below
    botPermissions: [ "SEND_MESSAGES" ],
    memberPermissions: [ "ADMINISTRATOR" ],
    guildOnly: true // command can only be run on a server
});

// Register base commands
bot.addCommand("ping", {
    run: BaseCommands.ping.data.run
});

// Define Discord.js client options
bot.setClientOptions({
    fetchAllMembers: true
})
.connect(); // log in to Discord

// You can use events
bot.client.on("ready", () => {
    console.log("The bot is ready");
});
1.4.1

5 years ago

1.4.0

5 years ago