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

@devspeed/discord-client

v1.0.4

Published

A discordjs package that provide you with util functions and classes to help speed up your development

Downloads

9

Readme

Documentation

Invite to My Discord Server

if you find this package helpful, please consider supporting its development by making a donation: Donate

Please report any issues or bugs on our GitHub page so we can improve our services for everyone. github

Requirements

This package require disocrd.js to function.

Get Started

const { Loaders, RecursiveLoader, resgisterGuildCommand } = require("@devspeed/discord-client");
const { Client } = require("discord.js");

const client = new Client({
    intents: ["Guilds"]
});


Loaders.loadEvents(__dirname, { directory: "./events", client })


const { collection, JsonData } = RecursiveLoader.loadSlashCommands(__dirname, { directory: "./slash" });

// returns a collection
const messageCommand = RecursiveLoader.loadMessageCommands(__dirname, { directory: "commands" })

client.slashCommands = collection;

client.messageCommand = messageCommand;

console.log(client.slashCommands)
console.log(client.messageCommand)

resgisterGuildCommand({
    clientId: 'client id goes here',
    guilldId: 'guilid id goes here',
    token: "token goes here",
    commands: JsonData, //  the slash command loader already returns the collection and the jsonData
})

client.login("token goes");

The recursive loader will load every file in the specified directory, regardless of how deeply nested it is within your folder structure.If you prefer not to load every file in the specified directory, you can opt to use a regular loader instead see below for example

const { Loaders } = require("@devspeed/discord-client");

const collection = Loaders.loadSlashCommand(__dirname, { directory: '/slash'}); 

Adding filter

Loaders.loadSlashCommand(__dirname, { 
    directory: '/slash',
    filter: (file) => file.endsWith(".js") || file.endsWith("ts"), // the default value when filter is undefined
});

To extract the exported data object from only certain files within the specified directory, you can use the filter function. This function takes the currently iterated file as a parameter and returns a boolean value. If the boolean is true, the exported data object will be extracted.

defining slashCommand

const { SlashCommand } = require("@devspeed/discord-client")
const { SlashCommandBuilder } = require('discord.js');


module.exports = new SlashCommand({
    data: new SlashCommandBuilder()
        .setName("help")
        .setDescription("help command"),

    async execute(client, interaction) {
        await interaction.reply("pong"); 
    }
})

defining MessageCommand

const { MessageCommand } = require("@devspeed/discord-client");

module.exports = new MessageCommand({
    name: "ping",
    description: "A simple pong command",
    cooldown: 10,
    category: "general",
    enabled: true,
    execute: (client, message, args) => {
        console.log(client, message, args)
    }
})

defining Events

const { EventHandler } = require("@devspeed/discord-client");

module.exports = new EventHandler({
    name: "ready",
    execute(client, interaction) {
       /// console.log(`logined in as ${client.user.tag}`);

      console.log(client.user)
    }
})