discord-bot-lib

A basic discord bot library for node.js but the library doesn't cache discord objects.

Usage no npm install needed!

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

README

discord-bot-lib

A basic discord bot lib for node.js but the library doesn't cache discord objects.

Installation

$ npm install discord-bot-lib

Key points

  • Simple command handler.
  • Simple handler for slash commands.
  • This lib does NOT cache external discord objects.
  • This lib does NOT support voice (sorry music bots)
  • This lib gives you full control on how you cache discord data.
  • This lib gives you full control on how you handle discord gateway events.
  • Really customizable.

Links and Sections

Simple Bot Example

// require the lib
const Client = require('discord-bot-lib');

// create the client
const bot = new Client({
    token: "Discord Token",
    prefix: "/"
});

bot.addEventListener('ready', data => {
    console.log(`The bot is ready! Serving ${data.guilds.length} guilds.`);
});

bot.addEventListener('error', async (ctx, err) => {
    await ctx.send(`Whoopsies! The bot did an oopsie woopsie!\n\`${err}\``);
});

bot.addEventListener('close', () => console.log("Goodbye, world! :c"));

// simple command handler example
bot.command({
    name: "ping",
    aliases: ["pong"],
    run: async (ctx) => {
        return await ctx.send('Pong');
    }
});

// run the bot
bot.run();