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

@dubbyyt/maestro.js

v0.0.13

Published

A fast and simple discord.js framework

Downloads

19

Readme

MaestroJS

CI This framework aims for making the creation of discord bots with Discord.js easier and faster with rapid building techniques, less boiler plate, easier to read code, and further improvements upon the Discord.js framework.

What's the purpose of Maestro?

Maestro aims to make the initial setup and scalability of your discord bot simple. I (MilesSRC), noticed that getting a discord bot's foundations setup was a pain. I decided to create MaestroJS to remedy that inital daunting task. As well as providing some simple and depended on utility for use in peoples projects.

Quick Start

To get started with Maestro, create an Application class.

import { Application, Command, Event } from "@dubbyyt/maestro.js"
import { SlashCommandBuilder, Client, CommandInteraction } from "discord.js"

const MyApp = new Application({
    name: "Really Cool Bot",

    commands: [
        new Command({
            data: new SlashCommandBuilder()
                    .setName("ping")
                    .setDescription("Ping my cool bot!"),
            
            // Execute MUST be asyncronious, non-async functions aren't supported.
            execute: async (interaction: CommandInteraction, app: Application){
                interaction.reply("Hello world!")
            }
        })
    ],

    events: [
        new Event({
            name: "ready"
            handler: (client: Client) {
                console.log(`${client.user?.tag} is ready!`)
            }
        })
    ]
})

// Middleware (new to 0.0.11)
MyApp.on("commandError", (
    error: Error, 
    interaction: CommandInteraction, 
    command: Command
) => {
    // Maestro gives you 1.5s to either defer the reply or reply until it 
    // automatically sends a default error message to the user.
    interaction.reply("I'm sorry! It looks like I wasn't cool enough to execute that command. Try again later.")
})

// Authorize will automatically pull "BOT_TOKEN" from env 
// if no argument is provided to authorize.
MyApp.authorize()

// If you aren't storing your token in env (bad idea), 
// put it there in the first argument
MyApp.authorize("etcetcetcetcetcetc.etcetc.etcetcetc")

File Based Commands & Events

You can use FileBasedCommands(directory: string) and FileBasedEvents(directory: string) to grab events and commands from the file system of your project.

src/index.js

import { Application, FileBasedCommands, FileBasedEvents } from "@dubbyyt/maestro.js"
import path from 'path'

const MyApp = new Application({
    name: "Really Cool Bot",

    // Command and event arrays will be automatically populated 
    // with commands and events from your project.
    // Nesting in folders isn't supported yet. 
    // Please keep command and event files visible from top level in that directory. 
    commands: new FileBasedCommands(path.join(__dirname, 'commands/')),
    events: new FileBasedEvents(path.join(__dirname, 'events/'))
})

// Authorize will automatically pull "BOT_TOKEN" from env 
// if no argument is provided to authorize.
MyApp.authorize()

src/commands/ping.js

import { Command } from "@dubbyyt/maestro.js"
import { SlashCommandBuilder } from 'discord.js'

export default new Command({
    data: new SlashCommandBuilder()
            .setName("ping")
            .setDescription("Ping my cool bot!"),
    
    // Execute MUST be asyncronious, non-async functions aren't supported.
    execute: async (interaction: CommandInteraction, app: Application){
        interaction.reply("Hello world!")
    }
});

src/events/ready.ts

import { Event } from "@dubbyyt/maestro.js"

export default new Event({
    name: "ready",
    handler: (client: Client) {
        console.log(`${client.user?.tag} is ready!`)
    }
})

Side Note

If you aren't using typescript, you can put your event/command straight into module.exports

// src/commands/ping.js
const { Command } = require("@dubbyyt/maestro.js")
const { SlashCommandBuilder } = require("discord.js")

module.exports = new Command({
    data: new SlashCommandBuilder()
            .setName("ping")
            .setDescription("Ping my cool bot!"),
    
    // Execute MUST be asyncronious, non-async functions aren't supported.
    execute: async (interaction: CommandInteraction, app: Application){
        interaction.reply("Hello world!")
    }
});