2.0.7 • Published 4 years ago

@natchi/discordjs-handler v2.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

discordjs-handler

Module qui permet d'exécuter des événements ou des commandes ou des interactions pour discord.js en handler.

Liens

Installation

Nodejs >v16.6.0 requis.
Via npm:

npm install @natchi/discordjs-handler

Via Yarn:

yarn add @natchi/discordjs-handler

Configuration

Vous avez juste à importer la fonction handler dans votre projet et l'utilisé qu'une seule fois dans un de vos fichiers.
Celui ci va crée automatiquement des Collections pour les différentes utilités: commands, events, slashCommands, buttons, et selectMenus.
Vous pourrez retrouvez ces collections depuis client.handler.$.
Bien sûr les choix des handlers à éxécuter est optionnel, vous n'êtes pas obliger de préciser tous les chemins, cela est en fonction de votre utilisation.
Exemples
Javascript

const { handler } = require("@natchi/discordjs-handler");

(async () => {
  await handler(
    client,
    {
      events: "./events",
      commands: "./commands",
      slashCommands: "./interactions/slashcommands",
      buttons: "./interactions/buttons",
      selectMenus: "./interactions/selectmenus",
    },
    {
      lang: "js",
    }
  );
})();

Typescript

import { handler } from "@natchi/discordjs-handler";

(async () => {
  await handler(
    client,
    {
      events: "./events",
      commands: "./commands",
      slashCommands: "./interactions/slashcommands",
      buttons: "./interactions/buttons",
      selectMenus: "./interactions/selectmenus",
    },
    {
      lang: "ts",
    }
  );
})();

Pour les fichiers d'événements ou de commandes, ou d'intéractions voici le schéma à suivre selon le langage.
Pout le langage Typescript, l'export des événements doit se faire obligatoirement par une constante en respectant le nom de celles ci en fonction de ce que vous voulez exporter.

  • Evénements: event
  • Commandes: command
  • SlashCommands: slashCommand
  • Buttons: button
  • SelectMenus: button

Exemple
Javascript

// Fichier message.js
module.exports = {
  name: "message",
  run: (client, message) => {
    // ...
  },
};

// Fichier ping.js
module.exports = {
  name: "ping",
  category: "Fun", // Facultatif
  description: "Permet de faire Ping Pong", // Facultatif
  aliases: ["p"], // Facultatif
  run: (client, message, args) => {
    // ...
  },
};

// Fichier pingSlash.js
module.exports = {
  name: "ping",
  description: "Permet de faire Ping Pong",
  run: (client, interaction) => {
    // ...
  },
};

Typescript

// Fichier message.ts
import { Event } from "@natchi/discordjs-handler";

export const event: Event = {
  name: "message",
  run: (client, message) => {
    // ...
  },
};

// Fichier ping.ts
import { Command } from "@natchi/discordjs-handler";

export const command: Command = {
  name: "ping",
  category: "Fun", // Facultatif
  description: "Permet de faire Ping Pong", // Facultatif
  alises: ["p"], // Facultatif
  run: (client, message, args) => {
    // ...
  },
};

// Fichier pingSlash.ts
import { SlashCommand } from "@natchi/discordjs-handler";

export const slashCommand: SlashCommand = {
  name: "ping",
  description: "Permet de faire Ping Pong",
  run: (client, interaction) => {
    // ...
  },
};
2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.4

4 years ago

2.0.0-dev.0.0.1

4 years ago

2.0.1

4 years ago

2.0.0-dev.0.0.3

4 years ago

2.0.0

4 years ago

2.0.0-dev.0.0.2

4 years ago

1.3.2

4 years ago

1.2.0

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago