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

fast-discord-js

v1.1.0

Published

FastDiscordJS is an unofficial extension of the 'discord.js' library. Our extension aims to simplify the development of Discord bots, promoting cleaner code and easier maintenance.

Downloads

459

Readme

FastDiscordJS

Fast Discord JS is an unofficial extension of the "discord.js" library. Our extension aims to simplify the development of Discord bots, promoting cleaner code and easier maintenance.

Features

  • Error prevention with user-friendly messages
  • Callback functions
  • Less code, more efficiency
  • Code and performance optimization

Installation

npm install fast-discord-js

Get starting

import { GatewayIntentBits } from "discord.js";
import { Client } from "fast-discord-js";

const client = new Client({ autoImport: ["./components", "./commands"], intents: [GatewayIntentBits.MessageContent]});
client.login("YOUR-TOKEN-HERE")

client.on("ready", (client) => {
    console.log("Online! Client:", client.user?.username)
})

Autoload and Intents are optional. If no Intent is provided, all intents will be sent to discord.

Autoload is a list of folder paths that will be automatically imported by the system, without the need to use import or require, facilitating the workflow with discord

Creating a Slash Commands

import { ApplicationCommandType } from "discord.js";
import { SlashCommand } from "../../src";

new SlashCommand({
    name: "commandtest",
    description: "Testing slash command system",
    type: ApplicationCommandType.ChatInput,
    run: async (client, interaction) => {
        return interaction.reply({content: `Hello World!`, ephemeral: true});
    }
})

This code creates a slash command called "commandtest", and so this command to execute the "run" function will be called.

Invoking Interaction

new SlashCommand({
    name: "test",
    description: "testing",
    type: ApplicationCommandType.ChatInput,
    run: async (client, interaction) => {

        // Using client.invokeInteraction to invoke other interaction
        client.invokeInteraction("say-hello", interaction);
    }
})

new InteractionHandler({
    customId: "say-hello",
    run: async (client, interaction) => {
        return interaction.reply("I was invoked by the test command! Hello World :)")
    }
})

In the code above we created a command that invokes an interaction with the customId "say-hello". When this interaction is invoked, it uses the reply method to respond to this interaction. Note that the interaction received by InteractionHandler is the same interaction that was received by SlashCommand, so this function will not generate a different interaction, just take advantage of the existing one.

Below, we will take a deeper look at InteractionHandler

Interaction Handlers

new InteractionHandler({
    customId: "test2",
    run: async (client, interaction) => {
        return interaction.reply("I was invoked by the test command!")
    }
})

This code defines a handler for an interaction with a specific name, as soon as this interaction is issued through some component (button, modal or select) the InteractionHandler "run" function will be called.

Interaction Handler With Parameters

new SlashCommand({
    name: "test",
    description: "testing",
    type: ApplicationCommandType.ChatInput,
    run: async (client, interaction) => {

        // Using client.invokeInteraction to invoke other interaction and passing two parameters splited by ":"
        client.invokeInteraction("say-hello-with-parameters:lorem:ipsum", interaction);
    }
})

new InteractionHandler({
    customId: "say-hello",
    useParams: true, // its necessary if your use params
    
    run: async (client, interaction, param1, param2) => {
        console.log(param1, param2) // return: "lorem, ipsum" recived by parameters in SlashCommand
        return interaction.reply("I was invoked by the test command! Hello World :)")
    }
})

In the example above we call a handler passing parameters to it through invokeInteraction in SlashCommand, but it is good to remember that parameters can be sent through components, such as Button, Modal, Select...

If no parameters are sent, the values ​​received in the interactionHandler run will be "undefined".

Authors