Romejanic / slasher

A framework to simplify the creation of Discord bots.
MIT License
3 stars 2 forks source link


Logo

Frighteningly simple slash commands
Documentation »

Report Bug · Request Feature

Slasher is a framework to simplify the creation of Discord bots.

Forget about SlashCommandBuilder and REST. Slasher takes care of all of it for you, and provides a simple, easy-to-use interface to build your bot using slash commands.

Even if you're not using discord.js to build your bot, you can still make use of the handy CLI tool to make adding slash commands painless!

Slasher currently supports discord.js v14 ONLY. The package will no longer work with v13.

Guides

If you are using Slasher for the first time, please see the Getting Started guide.

If you are migrating an existing bot, please see the Slasher Migration guide.

Install

Install for use in a node project

npm i -s discord.js discord.js-slasher

Install the CLI tool for another language

npm i -g discord.js-slasher

Example

First we create our commands.json definition file:

{
    "test": {
        "description": "My first command on Discord!"
    }
}

Then run the slasher utility and follow the prompts to upload it to Discord!

$ npx slasher

Then we can create our bot!

const { Events } = require("discord.js");
const { SlasherClient, SlasherEvents } = require("discord.js-slasher");
// alternatively use import statements

const client = new SlasherClient();

client.on(Events.ClientReady, () => {
    console.log("Logged in as " + client.user.tag);
});

client.on(SlasherEvents.CommandCreate, (ctx) => {
    ctx.reply(`Howdy ${ctx.user.tag}!`);
});

client.login();

Thanks