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

disbun

v2.0.1

Published

<p align="center"> <img src="https://user-images.githubusercontent.com/709451/182802334-d9c42afe-f35d-4a7b-86ea-9985f73f20c3.png" width="200" /> </p>

Downloads

4

Readme

Disbun

disbun is a discord js command handler optimized for speed by using native bun functions.

Getting Started

As bun has built-in typescript compilation, this library will not work with NodeJS. Support may come soon but for now, it is not supported.

Prerequisites

You will need to have bun installed globally on your machine.

Installing Bun

Windows

npm i -g bun

Linux

curl -fsSL https://bun.sh/install | bash

Installing disbun CLI

bun add --global disbun-cli

Initializing a project

Starting a project with disbun is easy. Just run the following command in your terminal:

disbun

Now the good stuff

Now we'll go through setting up your client, adding commands, setting up middleware, MongoDB, and creating events.

Setting up the client

It's as simple as this:

import { Client } from "disbun";

new Client({
  commandsDir: "src/commands",
  intents: ["Guilds", "GuildMessages", "MessageContent"], // Message content intent required if you're using prefixed commands
}).login(process.env.BOT_TOKEN);

All methods on the client class

import { Client } from "disbun";

const client = new Client({
  commandsDir: "src/commands";
  eventsDir: "src/events";
  middleware: "src/middleware"; // Runs as raw data when interactions or messages are created
  testServers: ["guild id"],
  intents: ["Guilds", "GuildMessages"];
  mongo: {
    uri: "mongo uri" OR {
      username: string;
      password: string;
      host: string;
      port: number;
      database: string;
    };
    options: ConnectionOptions;
  }
}).setPrefix(string)

client.on("event", () => {

})

client.login(string);

Adding commands

Adding commands are almost as easy as setting up the project, just use the following CLI command or create a file and copy the template below.

disbun-cli add
import { Command, CommandType } from "disbun";

export default {
  name: "ping",
  description: "Returns funny message",
  type: CommandType.SLASH, // Or CommandType.MESSAGE for legacy commands
  run: async ({ interaction }) => {
    return "Pong!";
  },
} as Command;

All command methods

import { Command, CommandType } from "disbun";

export default {
  name: "pong",
  description: "Returns very unfunny message.",
  type: CommandType.SLASH,
  testOnly: true, // To be used with testServers in client options
  guilds: ["guild id"], // Enable test only for specific guilds without changing testServers
  permission: "Administrator",
  data: {
    my: "custom data :O",
    custom: true,
    command: 1,
    data: [],
  }
  options: [], // For slash command arguments
  run: async ({
    message, // Message object for legacy commands
    interaction, // Interaction object for slash commands
    args,
    client,
    member,
    guild,
    channel,
    author,
    data,
  }) => {
    return `${data.my} ${data.custom} ${data.command} ${data.data}`
  }
} as Command<{
  my: string;
  custom: boolean;
  command: number;
  data: Array<unknown>;
}>;

Adding events

Just like commands, adding events is easy. Not sure how many more times I can say that.

disbun-cli add
import { Client } from "disbun";

export default (client: Client) => {
  client.on("event", () => {
    // Do stuff
  });
};

Middleware

Middleware is a way to run code before commands are executed. This is useful for things like cooldowns, permissions, and more.

NOTE: Middleware MUST return a Middleware code (yes it's just true and false, the enum is for code readability). You can use the Middleware enum to return proper codes.

middleware/index.ts

import { IMiddlewareOptions, Middleware } from "disbun";

export default async ({ client, interaction, message }: IMiddlewareOptions) => {
  if (interaction.isCommand()) return Middleware.SUCCESS;
};

:warning: This project is currently under development and not ready for a production environment