@discordx/socket.io
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Discord server NPM version NPM downloads Build status paypal

Create a discord bot with TypeScript and Decorators!

📖 Introduction

This module is an extension of socket.io, so the internal behavior (methods, properties, ...) is the same

This library allows you to use TypeScript decorators on socket.io, it simplifies your code and improves the readability!

💻 Installation

Version 16.6.0 or newer of Node.js is required

npm install socket.io @discordx/socket.io
yarn add socket.io @discordx/socket.io

🆕 Features

  • Support multiple server in a single nodejs instance (@AppId)
  • Support TSyringe
  • Support ECMAScript

📟 @On/@Once

do not forget to wrap each class with @Ws()

import { Guard, Next, On, Once, Server, Ws } from "@discordx/socket.io";
import { Socket } from "socket.io";

@Ws()
class Example {
  @On("connection")
  @Guard(([]: [Socket], server: Server, socket: unknown, next: Next) => {
    console.log("I am mdw");
    return next();
  })
  on(): void {
    console.log("I am @onx");
  }

  @On("disconnect")
  disconnect(): void {
    console.log("I am disconnect");
  }

  @Once("connection")
  once(): void {
    console.log("I am @Once");
  }
}

📜 Documentation

☎️ Need help?

💖 Thank you

You can support discordx by giving it a GitHub star.

Package Sidebar

Install

npm i @discordx/socket.io

Weekly Downloads

24

Version

1.1.1

License

Apache-2.0

Unpacked Size

39.3 kB

Total Files

9

Last publish

Collaborators

  • samarmeena