kabirsingh2004 / discordjs-base-handler Goto Github PK
View Code? Open in Web Editor NEWImprove Discord.js bot with organized Slash Commands, events, and error handling. Use discord.js, Node.js.
License: MIT License
Improve Discord.js bot with organized Slash Commands, events, and error handling. Use discord.js, Node.js.
License: MIT License
\events\messageCreate.js:16
const args = message.content.slice(nprefix.length).trim().split(/ +/);
^
TypeError: Cannot read properties of null (reading 'length')
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 useeditReply
because, i mean, the namefollowUp
tells that it is for a followed up reply to an interaction, when you are just sending aTYPE 5
not aTYPE 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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.