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

discord-selene

v1.1.5

Published

A class based Command / Event handler for discord.js

Downloads

7

Readme

Selene

A command handler / extension to discord.js with some creature comforts and basic classes to ease the creation of discord bots with full support for typescript. It can be installed with npm install discord-selene. The three basic classes right now are:

  • Event - An event that can be passed to the client that will automatically be bound to a client event
  • Command - A basic command class that can be executed with cmd.execute(), it has some properties that work with the default command handler to provide basic functionality.
  • Client - The magic client class that loads the events and handlers. This can be configured in the constructor to load custom handlers and responses to errors / timeouts etc. (timeout functionality provided by the basic command handler)

Defaults:

  • command handler - Command handler with error catching, returned message payloads from Commands will automatically be sent as a reply, this can be replaced easily in the client init.
  • interaction handler - Interaction handler with error catching, returned message payloads from Commands will automatically be sent as a reply, this can be replaced easily in the client init. All of the above should be relatively self-explanatory and have sensible typing which should provide intelligent autofill.

Planned Features:

  • Help command (possibly)

Example Code:

import { Command, Event, EventBuilder, Client } from 'discord-selene';
import { CommandInteraction, Message, SlashCommandBuilder } from 'discord.js';
require('dotenv').config() // allow for use of .env files

let test = new Command({
	name: 'test', // name of the command
	description: 'test desc', // description for help command (coming soon!)
	category: 'util', // category for help command (coming soon!)
	usage: 'test <args>', // code to display on help command (coming soon!)
	timeout: 30000, // timeout in ms for default command handler
	slashData: new SlashCommandBuilder().setName('test').setDescription('test desc'), // optional data, adds slash command
	execute: async (client: Client, message: Message, args: string[]) => { // function to call when command is triggered
		return { content: 'test' }
	},
	slashExecute: async (client: Client, interaction: CommandInteraction) => { // function to call when slash command is triggered
		return { content: 'test' }
	}
})

let ready = new Event({
	name: 'ready', // name of the client event
	once: true, // run once?
	execute: (client: Client) => { // the listener
		console.log(`Ready as ${client.user?.tag}`)
	}
})
let readyBuilt = new EventBuilder().setName('ready').setOnce('true').setExecute(
	(client: Client) => {
		console.log(`Ready as ${client.user?.tag}`)
	}
)


let client = new Client({
	prefix: 't!', // prefix for default command handler
	commands: [test], // commands
	events: [ready, readyBuilt], // client events
	messages: { // message templates
		timeout: 'You need to wait {T} seconds before using this command again.',
		error: 'An error occurred:\n`{E}.`',
		nsfw: 'This command can only be run in an nsfw channel.'
	},
	clientOpts: { // default discordjs client options
		intents: ["MessageContent", "GuildMessages", "GuildMembers", "Guilds"]
	}
})

client.login(process.env.TOKEN).then(() => {
	//void client.deployGuild("GUILDID") // deploy all slash commmands to a specific guild
    //void client.deployGlobal() // deploy all slash commands globally, may take up to 1 hour to propagate
})