Giter Club home page Giter Club logo

kabirsingh2004 / discordjs-base-handler Goto Github PK

View Code? Open in Web Editor NEW
130.0 4.0 60.0 213 KB

Improve Discord.js bot with organized Slash Commands, events, and error handling. Use discord.js, Node.js.

License: MIT License

JavaScript 100.00%
discord-bot discord-js discord commandhandler discordjsv14 basehandler eventhandler discordjs discord-handler bot discord-api discordapp discordbot nodejs discord-js-handler discord-js-handler-v14 discord-js-v14 node-js slash-commands-handler

discordjs-base-handler's Introduction

Hi, I'm Kabir! ๐Ÿ‘‹

I'm a Discord Bot Developer and here is mine bot handler

Installation | How to use the Handler

  1. Clone this repository.
  2. Fill in the required details in settings/config.js.
  3. Run npm install to install dependencies.
  4. Start the bot with node index.js.

Modify - config.js

import { Colors } from "discord.js";

const settings = {
  TOKEN: process.env.TOKEN || "BOT_TOKEN",
  PREFIX: process.env.PREFIX || "BOT_PREFIX",
  Owners: ["OwnersId", "OwnersId"],
  Slash: {
    Global: false,
    GuildID: process.env.GuildID || "GUILD_ID",
  },
};

export default settings;

Handler Features

  • Easy-to-use Handler
  • Event handling support
  • Slash commands
  • Message commands
  • Built on discord.js
  • Code snippets for commands
  • Subdirectory support in the commands folder
  • Code suggestions in Handler

Feedback

If you have any feedback or need assistance, please join out Discord Server

Usage/Examples

  • Commands Example

Slash Chat Input Command

import { ApplicationCommandType, PermissionFlagsBits } from "discord.js";

/**
 * @type {import("../../../index.js").Scommand}
 */
export default {
  name: "",
  description: "",
  userPermissions: [PermissionFlagsBits.SendMessages],
  botPermissions: [
    PermissionFlagsBits.SendMessages,
    PermissionFlagsBits.EmbedLinks,
  ],
  category: "",
  type: ApplicationCommandType.ChatInput,

  run: async ({ client, interaction }) => {
    // Code
  },
};

Slash Message Input Command

import { ApplicationCommandType } from "discord.js";

/**
 * @type {import("../../..").CMcommand}
 */
export default {
  name: "",
  category: "",
  type: ApplicationCommandType.Message,

  run: async ({ client, interaction }) => {
    // Code
  },
};

Slash User Input Command

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

/**
 * @type {import("../../..").CUcommand}
 */
export default {
  name: "",
  category: "",
  type: ApplicationCommandType.User,

  run: async ({ client, interaction }) => {
    // Code
  },
};

Message/Prefix Command

import { PermissionFlagsBits } from "discord.js";

/**
 * @type {import("../../../index.js").Mcommand}
 */
export default {
  name: "",
  description: "",
  userPermissions: [PermissionFlagsBits.SendMessages],
  botPermissions: [
    PermissionFlagsBits.SendMessages,
    PermissionFlagsBits.EmbedLinks,
  ],
  category: "",
  cooldown: 5,

  run: async ({ client, message, args, prefix }) => {
    // Code
  },
};

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

Thank you for considering the use of Kabir's Discord Bot Handler! If you find it helpful, we encourage you to give it a โญ๏ธ.

Contributing

If you encounter any bugs or have suggestions for improvement, please open a pull request. Your contributions are highly appreciated!

Support

For any inquiries or assistance, feel free to reach out to us on our Discord Server.

Happy coding! ๐Ÿš€

discordjs-base-handler's People

Contributors

kabirjaipal avatar t6x01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

discordjs-base-handler's Issues

certainly not the best interaction handler or, yeah not something i would suggest

your event handler has a few things to be made better

the way you are dealing with the interactions won't be the best for the buttons since you are first checking if the INTERACTION_CREATE event gives you a component type or not, i would suggest you to first check for the event having components and then check for the slash commands because you are using a require cache type handler which would fail the interactions when you add many commands

you are deffering the interaction response from the event handler which is TOTALLY NOT THE BEST THING TO DO, i would suggest you to defer the interaction from the command files and then do stuff

once go through https://discord.dev/ you are replying with a followUp to a deferred interaction which works well for now, but further more i would suggest you to use editReply because, i mean, the name followUp tells that it is for a followed up reply to an interaction, when you are just sending a TYPE 5 not a TYPE 4,

the way you are handling the interaction.defer() error, thats wrong, you are not alerting the user that there has been an error internally in the code, so yeah send a ephemeral (flags 64) type 4 reply saying that there was an error hence the command won't be ran further more

Error

\events\messageCreate.js:16
const args = message.content.slice(nprefix.length).trim().split(/ +/);
^

TypeError: Cannot read properties of null (reading 'length')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.