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

@clemens_e/shori

v1.0.16

Published

Simple Typescript discord.js framework

Downloads

1

Readme

Shori

Simple Typescript discord.js framework providing decorators and DI


Should I use this?

probably not.

Usage

Start by extending the ShoriClient, like this:

class ExampleClient extends ShoriClient {

  constructor(shoriOptions: ShoriOptions, clientOptions: ClientOptions) {
    super(shoriOptions, clientOptions);
  }

  public getPrefix(id: string): Promise<string> {
    // should make a database request here
    // returning undefined will make it use the default prefix
    return undefined;
  }
  
}

Commands

Commands have to extend the CommandBase class and have the Command Decorator

@Command('test')
class TestCommand extends CommandBase {

  // shori provide dependency injection with tsyringe
  // on how to provide a service, read down below in the Service chapter
  constructor(private fileService: FileService) {super();}

  public async exec(message: Message, args: string[]): Promise<any> {
    message.reply( `hi, this works. My Prefix: ${this.client.prefix}` );
  }

}

Services

A Service is a class that provides methods and actions for your project, for example a class that provides methods to interact with the filesystem, you dont want that logic inside your commands.

@Service()
export class FileService {

  public async init(): Promise<void> {
    // run things that your service needs to fully work,
    // this method will be called and awaited before the client starts
    // e.g. creating database connections, ensuring folders etc...
    await this.doStuff();
  }
  
}

The @Service() decorator will make the class a singleton, and thus can be injected into commands (or any other knows class in the shori context)

Its important to know that every Service must be provided in the service array in the shori client options.

shori will then call every services init method and wait for its Promise to resolve before the client starts the connection to discord

Events

Events simply have to be decorated with an Event Decorator

import {Client, Event} from 'shori';

export class SomeClass {

  // shori will inject the client  
  @Client() 
  private client: ExampleClient

  @Event('ready')
  ready(): void {
    console.log('client is ready');
    console.log(this.client.channels.size);
  }

}

Warning:
shori will register every class you use @Command , @Event or @Service on as a singleton, do not create instances yourself, but use DI or container.resolve from tsyringe