Socket
Book a DemoInstallSign in
Socket

@hades-ts/hades

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hades-ts/hades

Typescript framework using Inversify.js and Discord.js

0.0.7
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

Hades

Typescript bot framework using Inversify.js and Discord.js.

hades.png

    Hades is a dependency-injection oriented framework. 
    Read more about DI here and here.

Installation

Install the latest version from Git using NPM:

npm i --save https://github.com/dustinlacewell/hades.git

Example

You can try a simple example bot here:

https://github.com/dustinlacewell/hades-example-bot

Getting Started

The basic bot starts with extending HadesBotService:

import { HadesBotService, singleton } from "hades";

@singleton(BotService)
export class BotService extends HadesBotService {
  async onReady() {
    console.log(`Logged in as ${this.client.user.username}.`);
  }
}

BotService.onReady() will be called when the associated Discord.js event is fired and in this case log a message to the console.

We're using the @singleton() decorator here to bind BotService to itself within the container as a singleton.

Container Setup

In our index.ts we can configure the container:

import "reflect-metadata";

import { HadesContainer } from "hades";
import { installTextCommands } from "hades/dist/text-commands";

import { BotService } from "./services/BotService";

const container = new HadesContainer();
const bot = container.get(BotService);
bot.login();

In order for dependency injection to work, we need to import reflect-metadata. Just a fact of life.

After creating the HadesContainer we can then request an instance of our BotService.

We can finally login to Discord as the bot.

Writing the Config

Add your token to config/default.json:

{
  "discordToken": "your bot token here"
}

That's it. The bot should now boot up and connect to any servers you've added it to. Of course it doesn't do anything...yet!

Documentation

Please visit our documentation for more information:

Looking to contribute? Check out our Contributor Documentation.

FAQs

Package last updated on 02 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.