Coder Social home page Coder Social logo

rilecraft / discordbot-template Goto Github PK

View Code? Open in Web Editor NEW
208.0 5.0 61.0 445 KB

A bot template with command , event , button , selectmenus , slashcommands handler and error handlers. Made in Discord.JS V14

License: MIT License

JavaScript 100.00%
discord discord-bot discord-js discord-api discord-js-v13-handler discord-js-v13-reload-command discord-js-v13 discord-js-event-handler discord-js-v13-selectmenus djs-handler

discordbot-template's Introduction


Discord Bot Template

The Discord Bot Template provides a solid foundation for creating feature-rich Discord bots using Discord.js. It includes various managers for handling message commands, buttons, select menus, slash commands, context menus, and modal forms. The template offers customization options, colorful logging, and a simple code structure.

Changelog

IMPORTANT UPDATE 9.0.6

  • Fixed Windows Support and SlashCommands & ContextMenus not Registering.
  • Fixed subDirectories not working for commands.
  • Added dependency of simple-json-db for the cooldown system as i rage quit and can't do it with fs myself.
  • Latest Discord.js adaptation.
  • Following JavaScript Naming Convention.
  • Removed node-recursive-directory dependency.
  • Support for AutoCompleteInteraction added.
  • Converted from CommonJS to ESM Module.
  • Improved handling of all events, commands with lower memory usage.
  • Config file has been shifted to Src.
  • Moved from Collections to Map.
  • messageCommandsAliases has been renamed to messageCommands_Aliases
  • Quick.DB has been removed and instead all cooldowns data will be now stored in CooldownDB.txt in the root directory using fs.
  • Refactored command options.
  • chalk has been replaced with tasai.
  • Extended all command options support to interactions.
  • SlashCommands and ContextMenus has been seperated into different folders and managed differently.
  • SlashCommands have been simplified as now instead of Guilds/<GuildID>/<Files Here>, you can use guilds: ["GUILD ID"]
  • In a slashCommand you do not need to assign the type: ApplicationCommandType property as the handler by default assumes it as ChatInput.

Documentation

For detailed documentation on command options and managers, please refer to the following links:

Command Options

Managers

Features

  • Colorful and organized logging.
  • Customization options to suit your needs.
  • Supports management of message commands, buttons, select menus, slash commands, context menus, and modal forms.
  • Includes a variety of commonly used command options (not applicable to events).
  • Supports management of custom events.
  • Simple and understandable code structure.

Notes

  • Recommended Node.js version: 16 and above.
  • Global slash commands and context menus may take time to refresh as it is controlled by Discord.
  • Guild commands may take time to refresh if there are a large number of different guild commands.
  • Collections where command and event data is stored and used:
    • <Client>.messageCommands: Message commands cache
    • <Client>.messageCommands_Aliases: Message command aliases cache
    • <Client>.events: Client events cache
    • <Client>.buttonCommands: Button interactions cache
    • <Client>.selectMenus: Select menu interactions cache
    • <Client>.modalForms: Modal form interactions cache
    • <Client>.slashCommands: Slash commands cache
    • <Client>.contextMenus: ContextMenus commands cache

Installation

To get started with the Discord Bot Template, follow these steps:

  1. Clone the repository by downloading it as a ZIP file or running the command git clone https://github.com/rilecraft/discordbot-template.
  2. Navigate to the template's directory and run the command npm install (make sure npm is installed).
  3. Once all the required modules are installed, open the src/config.js file and fill in the necessary information.
  4. Run the command node . to start the bot.

Contribution

Contributions to the Discord Bot Template are welcome. To contribute, please follow these guidelines:

  1. Fork the Unstable branch. Important: All changes must be made to the Unstable branch.
  2. Make your changes in your forked repository.
  3. Open a pull request to the Unstable branch, and it will be reviewed promptly.
  4. If everything checks out, the pull request will be merged.

discordbot-template's People

Contributors

dependabot[bot] avatar dipotatopelator avatar marcussaw123 avatar rilecraft avatar saunakghosh10 avatar shkourbashtawi avatar switchalpha avatar violet-vibes 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  avatar

discordbot-template's Issues

Excute an owner command but its not the owner

Describe the issue
When a member thats not a developer exceute a developers command like eval, it excute the command and after it send the message for ownerOnly. I have not errors

To Reproduce
I don't know what I changed

Expected behavior
don't execute the command

Screenshots

Host Details:

  • OS: Windows 11
  • NodeJS Version: 18.12.1

Additional context
I test with the template so I change nothing in the conde just the Config.js and it work and I changed the messageCreate with the original and it dosen't work too so, it don't execute the command. So I need to know where I need to look for execute the loadCommandOption and after the command

Prefix

When I ADD PREFIX
BOT WORK IN ANY PREFIX
THIS IS PREFIX
image
THIS IS COMMAND
image

Suggestion Request

It's possible, for you give us more info on you non client event, how it's work ?

it's for custom event, like one streamer up his stream and that mat an event or other thing ?

Test

Describe the issue
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Host Details:

  • OS: [e.g. iOS]
  • NodeJS Version: [eg: 16.1.0]

Additional context
Add any other context about the problem here.

How Can I Do This

if(i.member.id != interaction.user.id) {
return i.reply({ content: This interaction is not for you, ephemeral: true})
}

This Code Dosent work in btn handlar

Confused

I added my own guildMemberAdd.js event from a tutorial and tweaked it a little bit.
Code - https://pastebin.com/v5A6mxLV

unknown
I then get this error.

I've contacted discord.js public support but they told me i didnt define my root in "loadEvents.js Line 16"
What should I do?
(and yes i know i mentioned "discord-js", I already corrected that)

ERR_UNHANDLED_REJECTION Error

Describe the issue
iam use rainway host and he is perfect
but sometimes show this error idk why

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#".] {
code: 'ERR_UNHANDLED_REJECTION'
}

he say in promise so iam think because slash halnder or what?
iam try fix it but can't fixed

Screenshots
Screenshot_20220330-153007_Chrome

Suggestion Request: Update about section

Updating About section of repo
About section should be updated like this since D.js version is V14

A bot template with command , event , button , selectmenus , slashcommands , contextmenus handler and error handlers. Made in Discord.JS V14

What will this feature do?
Easier access to people in need.

Additional context
NaN

[ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'

Describe the issue
When trying to install the newest version I get a ERR_UNSUPPORTED_ESM_URL_SCHEME error. I just followed the install guide in the readme

To Reproduce
Steps to reproduce the behavior:

  1. Download the zip file from releases or from github with the code button
  2. Extract the zip file
  3. Open the folder
  4. Open a new terminal (If using VS Code)
  5. Type npm install
  6. Open the src folder
  7. Open the config.js file
  8. Change "Bot Prefix" to the prefix you want (I typed "!")
  9. Change "Bot Token" to your bot's token
  10. Change "Bot Owner Discord ID" to you discord ID
  11. Type node . in the terminal

Expected behavior
I would extect the bot to start, but I got an error.

Screenshots
Screenshot of the error:
ERR_UNSUPPORTED_ESM_URL_SCHEME error
Screenshot of my package.json file:
Package json file
Screenshot of the return I got when I ran the npm install command (I know it can't be used to anything but attached it anyway):
npm install return

Host Details:

  • OS: Windows 10
  • NodeJS Version: 21.6.1

customizable prefix

You might as well make a system where we can change the bot prefix by command, so you can have a different prefix for each guild

Bug in RequiredAnyRole

Describe the issue
When cheak RequiredAnyRole in command
console he will tell me error missing is not defined

Screenshots
Screenshot 2021-12-13 060732
Screenshot 2021-12-13 060742

Bot not responding

Well in fact, i have two errors. the first is the bot always stops responding after a certain time (it's not my host i checked with multiple bots). and the second sometimes it says in the console:
Loaded undefined commands/selectMenu/buttons/Events.

New bot with TypeScript

Name of the feature
TypeScript bot

What will this feature do?
You can do another repo or in this repo another bot but with TypeScript with the same commandOpts, etc...

Some Bugs

first thx for new big update
it is nice and eazy to read and learn

Describe the issue
1.
eval command if use button he will show this error and not delete button
Screenshot 2021-12-01 020858
Screenshot 2021-12-01 020907

2.
bot not load in console log ... but bot it running iam ..test ping command and he run
but in console log not show anything

3.
iam made command and add userPermissions but he tell me not have permmison
and iam owner server hhhhh
Screenshot 2021-12-01 035834
Screenshot 2021-12-01 035844

Slash Command Not Load

Describe the issue
Slash Command not load

Expected behavior
Problem show with last update (before 8 hours)
iam test in test guild and active guild command iam mean like that guild:["my guild test"],
and if add new command not load

iam try delete bot after that made bot and inite to guild ,all slash command not loaded
iam check if invite with applications.commands and yep iam invite with this scope

before this update everything work 100%

thx for help

Invalid interaction application command

Describe the issue
Some times bot the commands are not running, I know because the idea is global but any idea to fix or skip this problem from the last update yesterday

To Reproduce
Steps to reproduce the behavior:
See error

Screenshots
iam will add
Screenshot 2021-10-25 050406

Host Details:

  • Vesrion bot : last update (yesterday)
  • D.JS : V13.2.0
  • NodeJS Version: 16.11.0

Error when /command load & /command used

const {MessageEmbed} = require('discord.js')
module.exports = {
    name: "ban",
    description: "Run this to ban a member",
    guilds: ['778284574479482910','927848261207875595'],
    run: async(client,message ,interaction) => {
        if(!interaction.member.permission.has("BAN_MEMBERS"))
            return interaction.followUp({content: "Tu n'as pas les permissions pour utiliser cette commande", ephemeral: true})
        const user = interaction.options.getUser('user')
        const member = interaction.guild.members.cache.get(user.id) || await interaction.guild.members.fetch(user.id).catch(err => {})
        if(!member) return interaction.followup("😅 | Je ne peux pas avoir les details de se membre");
        const reason = interaction.options.getString('reason');
        if(!member.bannable || member.user.id === client.user.id)
            return interaction.followUp("😅 | Je ne peux pas ban ce membre");
        if(interaction.member.role.highest.position <= member.roles.highest.position)
            return interaction.followUp('Certains membres ont un rang supérieur ou égal au vôtre, je ne peux donc pas les bannir.')
        const ban = new MessageEmbed()
            .setDescription(`**${member.user.tag}** a été bannie de se serveur pour \`${reason}\``)
            .setColor('RANDOM')
            .setFooter({text: 'Ban Member'})
            .setTimestamp()
        await member.user.send(`Tu as étais bannie de **\`${interaction.guild.name}\`** for \`${reason}\``).catch(err => {})
        await member.ban({reason})
        return interaction.followUp({embeds: [ban]})
    }
}

when it's load give that error: error slashcommand

Select Menus won't respond.

Describe the issue
Select menus won't respond when I create a new select menu and then create a new select menu with the name set as the customId for the select menu, I have read the documentation, it says that I can either put the custom ID of the select menu or one of the option values. When I put the value, it works, but when I use the custom ID it does not and I know your probably gonna say "Well just use the values" but I don't want to as it means I have to create like 13 different files for one command and I don't want to do that. Is it something that I am doing wrong, or is something that is wrong with code.

Screenshots
When I use the customId of the select menu, nothing happens.

This is the message action row with the select menu.

When I use the select menu with the custom id, nothing happens nothing is logged in the console.
Link to the video
Host Details:

  • OS: Windows 11
  • NodeJS Version: [v18.2.0]
  • Discord.JS Version: [v13.6.0]

Additional context
Is it something that I am doing wrong, or is it something wrong with the source code?

User Options

Name of the feature
User Options, String Options

What will this feature do?
i don't know if it exist buts its like d.js slashcommandbuilder, like .addstringoption(), .adduseroption()
Additional context
if it already exist tell me on how to do use it

Suggestion Request

Name of the feature
Context Menu

What will this feature do?
Iam hope add Context Menu in this project

Ping command

Describe the issue
The ping command doesn't show actual results

To Reproduce
Steps to reproduce the behavior:

  1. Use the ping command and watch the results

Expected behavior
Bot should give us the real ping and not unreal results

Screenshots
image

Host Details:

  • OS: Windows
  • NodeJS Version: v16.14.0

Additional context
None

Slash Command don't load

I juste clone the project, and change config.js but slash command doesn't load after 30 min

OS : Win 11
Node : 16.13.1

Something is wrong with NPM

When I install the modules using:
npm -i It says

up to date, audited 1 package in 856ms
found 0 vulnerabilities```

I thought It installed it but the node says it wasn't.

Error Cooldown

` if (!command.cooldown) return false;
^

TypeError: Cannot read properties of undefined (reading 'cooldown')
at module.exports (/home/runner/saitama/Root/Classes/CommandOptions/Cooldown.js:2:18)
at module.exports (/home/runner/saitama/Root/Classes/CommandOptions/loadCommandOptions.js:5:75)
at Object.run (/home/runner/saitama/Root/Events/InteractionCreate.js:5:37)
at Client. (/home/runner/saitama/Root/Classes/Handlers/loadEvents.js:16:55)
at Client.emit (node:events:402:35)
at InteractionCreateAction.handle (/home/runner/saitama/node_modules/discord.js/src/client/actions/InteractionCreate.js:70:12)
at Object.module.exports [as INTERACTION_CREATE] (/home/runner/saitama/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/runner/saitama/node_modules/discord.js/src/client/websocket/WebSocketManager.js:350:31)
at WebSocketShard.onPacket (/home/runner/saitama/node_modules/discord.js/src/client/websocket/WebSocketShard.js:443:22)
at WebSocketShard.onMessage (/home/runner/saitama/node_modules/discord.js/src/client/websocket/WebSocketShard.js:300:10)`

Unknown interaction

when I run a slash command it gives this error on the terminal,

It doesn't always happen, sometimes the command works normally, but other times it doesn't work and this error occurs in the terminal.


[Error Mensagem] DiscordAPIError: Unknown interaction
[Error Localização] at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:349:13)

Unknown interaction

When I USE interaction Its Give Me This ERR :

DiscordAPIError[10062]: Unknown interaction
    at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:640:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async BurstHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:736:23)
    at async REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1387:22)
    at async ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:111:5)
    at async Object.run (/home/container/Src/Interactions/SlashCommands/Global/slashCommands/Moderation 🗼/Ban.js:60:4)
    at async Object.run (/home/container/Src/Events/InteractionCreate.js:19:49) {
  requestBody: { files: [], json: { type: 4, data: [Object] } },
  rawError: { message: 'Unknown interaction', code: 10062 },
  code: 10062,
  status: 404,
  method: 'POST',
  url: 'https://discord.com/api/v10/interactions/1100492361219457095/aW50ZXJhY3Rpb246MTEwMDQ5MjM2MTIxOTQ1NzA5NTpYcE1JeVpZNERMNjdQdFJHSG95QU5YZHVGZ3F5SUpTeVVydTJYVWR1aHpoUEdwR2hTNzNUU1pORDlqN3kwY3doRDA3VHF2eVZhazY0NEo5WWxjZThpQjhCQ3ZoZ3VEZDhCM1RaU01wMTNpaGJOUTFlMlBoVmwwYlRjeHM1NXdaRA/callback'
}

MongoDB

Name of the feature
Eg: Mongo DB support

What will this feature do?
it will support database to save level system, warn, etc

Additional context

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.