Introduction

Version

Here is the latest version of the module:

About module



Weekly Downloads :
Last 30 days Downloads :

Technology

This module is built with Javascript and NodeJs.

Getting Started

Prerequisites

You must know a minimum of JavaScript, NodeJs and Discord.js

You must also have NodeJs and a code editor installed on your server or computer.

WARNING

Install all the modules that are requested!

Installing

With all these modules, we are good!

                        
npm install simple-djs-handler discord.js path fs
                        
                    

Config

In your main file (index.js for exemple).

                        
const { BotClient } = require('simple-djs-handler');
const { GatewayIntentBits } = require('discord.js');

const botOptions = {
    token: 'YOUR_BOT_TOKEN',
    slashCommandsEnabled: true, // true required for the module to function properly!
    slashCommandsClientId: 'YOUR_BOT_ID',
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMembers,
        GatewayIntentBits.GuildMessages,
        // ... add other intents as needed
    ],
};

const client = new BotClient(botOptions);

client.start();
                        
                    

WARNING

Change YOUR_BOT_TOKEN to your bot's token and YOUR_BOT_ID to your bot's identifier.

NOTE

You can launch the bot now, the module will create the folders for you!

Events Folder

EventReady

In the folder ./events (./events/EventReady.js for exemple).

                        
const { BotEvent } = require('simple-djs-handler');
const { Events } = require('discord.js');

module.exports = new BotEvent({
    name: Events.ClientReady,
    once: true,
    execute(client) {        
        client.user.setActivity('Ouais')
    },
});
                        
                    

InteractionCreate

In the folder ./events (./events/InteractionCreate.js for exemple).

                        
const { BotEvent } = require('simple-djs-handler');
const { Events } = require('discord.js');

module.exports = new BotEvent({
    name: Events.InteractionCreate,
    async execute(interaction) {
        if (!interaction.isChatInputCommand()) return;

        const command = interaction.client.commands.get(interaction.commandName);

        if (!command) {
            console.log(`No order match ${interaction.commandName} was found.`)
            return;
        }

        try {
            await command.execute(interaction);
        } catch (error) {
            console.log(`Erreur lors du lancement d'une commande : ${error}`);
        }
    },
});
                        
                    

Commands Folder

Simple Command

In the folder ./commands (./commands/Simple.js for exemple).

                        
const { BotCommand } = require('simple-djs-handler');

module.exports = new BotCommand({
    name: 'simple',
    description: 'An simple example command without options',
    execute: async (interaction) => {
        interaction.reply({
            content: "it's a simple command !"
        })
    },
});
                        
                    

Options Command

In the folder ./commands (./commands/OptionString.js for exemple).

                        
const BotCommand = require('../path/to/BotCommand');

module.exports = new BotCommand({
    name: 'example',
    description: 'An example command with options',
    options: [
        // Add your custom options for SlashCommandBuilder here
        {
            name: 'example_option',
            description: 'An example option',
            type: 'STRING', // All options in the table below
            required: true, // false if it's not required
        },
        // ... other options
    ],
    execute: async (interaction) => {
        const stringOption = interaction.options.getString('exemple_option');
        // Your order logic here (see simple command example)
    },
});
                        
                    

WARNING

The option required: true; is obligatory ! Specify false if the option is not required !

Table Options

Options Possibility
Option Correspond
"STRING" getStringOption()
"USER" addUserOption()
"CHANNEL" addChannelOption()
"ROLE" addRoleOption()
"SUBCOMMAND" addSubcommand()
"SUB_COMMAND_GROUP" addSubcommandGroup()