broccosito / slash-handler

Discord.js V13 Slash Commands Handler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

slash-handler

slash-handler

Table of Contents

About

Discord.js Slash Command & Event Handler

Prerequisites

NodeJS 16.6.0 Or Higher

Getting Started

Install The Project Node Dependencies

npm install

Fill out the config.js

const { Intents } = require("discord.js");

const config = {
  bot: {
    token: "", // Your discord bot token, you must have authorized the bot with the application.commands scope in order to use slash commands

    intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS], // You can find the available intents on https://discord.js.org/#/docs/main/stable/class/Intents?scrollTo=s-FLAGS

    guildId: "", // Update this field to only register commands a guild, this will make the commands to load instantly in the selected gulld (Optional)
  },
};

module.exports = config;

Usage

Note: There are some examples of usage in the commands and events folder inside the src folder.

New Command Template

const { SlashCommandBuilder } = require("@discordjs/builders");

const { MessageEmbed } = require("discord.js");

module.exports = {
  data: new SlashCommandBuilder()

    .setName("command-name") // /command-name

    .setDescription("command description"),

  run: async (interaction) => {
    // code to run
  },
};

New event template

module.exports = {
  event: "event-name", // Name of the event e.g. 'ready'

  oneTime: false, // If set to true the event will only be fired once until the client is restarted

  run: async (i) => {
    // code to run
  },
};

Reporting Issues

Open a issue in the GitHub Repo and i will try to solve it ASAP

This is everything you need to know! Have a good one :)

About

Discord.js V13 Slash Commands Handler

License:MIT License


Languages

Language:JavaScript 100.0%