npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

botbrew

v1.0.4

Published

A npm package for easy creation of discord bots

Downloads

11

Readme

BotBrew

Introduction

BotBrew is a TypeScript-based npm package designed to facilitate the development of Discord bots, with a special emphasis on slash command functionality. This lightweight library is perfect for developers looking to streamline their bot development process with an easy-to-implement solution.

Features

  • Slash Command Support: Easily create and manage Discord slash commands.
  • TypeScript Integration: Take advantage of TypeScript for more reliable and maintainable code.
  • Modular Command Structure: Organize your commands in separate folders for better scalability.
  • Event Handling for Discord Events: Efficiently handle various Discord events.
  • Simplified Bot Development: Focus on your bot's functionality without worrying about boilerplate code.

Installation

Install BotBrew in your project with the following command:

npm install botbrew

Setting Up Your Bot

To set up your bot, add the following code in your main file:

require("dotenv").config();
import { Bot } from "botbrew";
import { GatewayIntentBits } from "discord.js";

const bot = new Bot(process.env.DISCORD_TOKEN!, [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages], __dirname);

Creating Slash Commands

  1. Create a folder named SlashCommands in the same scope as your main file.
  2. Inside SlashCommands, create a subfolder for each command, e.g., ping.
  3. In each command folder, create an index.ts file. For example, for a "ping" command:
import { SlashCommand } from "botbrew";
import { ChatInputCommandInteraction } from "discord.js";

module.exports = new SlashCommand()
    .setName("ping")
    .setDescription("Replies with pong!")
    .onExecute(async (interaction: ChatInputCommandInteraction) => {
        await interaction.reply("Pong!");
    });

BotBrew automatically scans the SlashCommands folder and adds these commands to your bot.

Creating Subcommands

  1. Create a SlashCommands folder in the same scope as your main file.
  2. Inside SlashCommands, create a subfolder for each command, e.g., echo.
  3. To add subcommands, create further subfolders within the command folder.

Example: Echo Command

Folder structure for echo command with once and twice subcommands:

SlashCommands
└── echo
    ├── index.ts
    ├── once
    │   └── index.ts
    └── twice
        └── index.ts

once/index.ts

import {SubCommand} from "botbrew";

module.exports = new SubCommand()
    .setDescription("Echoes your message!")
    .addStringOption(option => option
        .setName("message")
        .setDescription("The message to echo")
        .setRequired(true)
    )
    .onExecute(async (interaction) => {
        await interaction.reply((interaction.options.getString("message")!));
    });

twice/index.ts

import {SubCommand} from "botbrew";

module.exports = new SubCommand()
    .setDescription("Echoes your message twice!")
    .addStringOption(option => option
        .setName("message")
        .setDescription("The message to echo")
        .setRequired(true)
    )
    .onExecute(async (interaction) => {
        await interaction.reply((interaction.options.getString("message")!) + " " + (interaction.options.getString("message")!));
    });

index.ts

import {SlashCommand} from "botbrew";

module.exports = new SlashCommand()
    .setDescription("Echoes your message!");

Note: If no command name is provided, the name of the command folder is used as the command name. In this case, the command name is echo. and the subcommands are once and twice.

License

BotBrew is ISC licensed.