discord-slasho

A light framework to build modern discord.js bots with as little boilerplate as possible 🤖

Usage no npm install needed!

<script type="module">
  import discordSlasho from 'https://cdn.skypack.dev/discord-slasho';
</script>

README


GitHub license Release Tag Github Pages

⚠️ Slasho is under heavy development: Expect changes to the underlying API as we build things out!

Slasho is a minimal framework for making Discord bots. It's for bot developers who want a clean environment with the core functionality they need to dive straight into building their bots.

📌 Getting Started Guide

When using discord.js, developers run into a number of problems

  • A lot of boilerplate. It's not hard to write discord.js, but it can be difficult to maintain.
  • Slash command testing. Developers have to setup new workflows to test slash commands.
  • Lack of command/event handling utilities
  • No command lifecycle utilities to setup, validate, and deploy commands

Slasho is here to fix all of these problems!

Features

  • Uses modern Discord APIs and supports slash commands out of the box
  • No learning curve. Slasho builds on top of discord.js and works well with existing logic
  • Single-file commands/events, just create new files to extend the bot's functionality
  • Introduces command lifecycle utilities like init and validate
  • Slash command deployment for development and production cases
  • Shared state across commands

Installation

Use the package manager npm to install slasho.

npm install discord-slasho

How it works

Here's a very basic example of what a command in Slasho looks like

/* ./commands/ping.ts */
import { CommandInteraction } from "discord.js";
import { Command } from "discord-slasho";

export default {
  //Command metadata
  type: "slash",
  name: "ping",
  description: "ping pong!",
  //Options that you want discord to collect
  options: [
    {
      name: "user",
      description: "User to ping pong!",
      type: "USER",
      required: true,
    },
  ],
  //Main execution function, see Command Life Cycle in docs for more info
  execute({ interaction }) {
    interaction.reply(` 🏓 ${interaction.options.getUser("user").username}`);
  },
} as Command<CommandInteraction>;

📚 Please check out the docs for more information.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Make sure to lint 😉

Please make sure to update tests as appropriate.

License

MIT