Slash Command Error
node:events:492
throw er; // Unhandled 'error' event
^
TypeError: interaction.isChatInputCommand is not a function
at Object.execute (C:\Users\LoneDeveloper\Documents\Bots\events\interactionCreate.js:13:26)
at Client.<anonymous> (C:\Users\LoneDeveloper\Documents\Bots\index.js:24:50)
at Client.emit (node:events:514:28)
at InteractionCreateAction.handle (C:\Users\LoneDeveloper\Documents\Bots\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\LoneDeveloper\Documents\Bots\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\LoneDeveloper\Documents\Bots\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:\Users\LoneDeveloper\Documents\Bots\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (C:\Users\LoneDeveloper\Documents\Bots\node
_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.<anonymous> (C:\Users\LoneDeveloper\Documents\Bots\node_modules\@discordjs\ws\dist\index.js:1173:51)
at WebSocketShard.emit (C:\Users\LoneDeveloper\Documents\Bots\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:397:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
Node.js v20.5.1
13 Replies
Where do you actually bind the exported function to
client.on('interactionCreate', ...)
Also since you're in the server for sapphire, have you considered using sapphire instead of making your own framework?no bcuz in new
Well you did join the server and you got the welcome screen that clearly told you the purpose of the server :wtfummm:
oh wai
no im new to the discord bot dev
i plan on using sapphire after a bit of learning
I guess but this way you're learning poor practises that you're going to have to unlearn later.
do you have any recommendations then
Well yeah just starting your bot with sapphire from the get go. Follow the guide on the website and/or generate a template with the CLI and go from there.
The guide for Sapphire and its many utilities, plugins and related libraries can be found on our website
ok
this where i register the commands
The problem with your code is that you call
event.execute(client, ...args)
but then implement it as execute(interaction)
. So it's not an interaction but a client in the implementation. Either you have to implement it as execute(client, interaction)
or do what sapphire does and not pass client that way at all but use depdency injection.
You have to be mindful of the order of parameters when programming.Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:
- Read and understand docs
- Debug code
- Syntax
- NodeJS module system
If you aren't sure that your understanding of JavaScript is truly good enough to make a bot, you should try to continue learning first. Here are good resources to learn both Javascript and NodeJS:
- Codecademy: https://www.codecademy.com/learn/javascript
- Udemy: https://www.udemy.com/javascript-essentials/
- Eloquent JavaScript, free book: http://eloquentjavascript.net/
- You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
- JavaScript Garden: https://bonsaiden.github.io/JavaScript-Garden/
- JavaScript reference/docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
- Nodeschool: https://nodeschool.io/
- Pluralsight: https://www.codeschool.com/courses/real-time-web-with-node-js
Before you ask a question, you should ask these yourself:
1. Is this question related to JavaScript, or the library I am using?
- If it is the library you are using, go to the proper server. You would get better answers there.
2. Have I tried to google and/or check StackOverflow?
- Double-check that you can't find anywhere that can lead you to a solution online.
3. Have I tried to look on MDN or the library documentation?
- You should always check documentation to make sure you aren't missing any details.
4. Does my question make enough sense so that people can understand it, and do they understand what I am trying to accomplish?
- If no, revise your question. Give as much detail as possible. Include any error or code output that can help us help you.
5. Am I aware of what I am doing, and not just mindlessly copying and pasting?
- If you are just copying and pasting code from a guide, you are not going to be able to solve anything. Make sure you understand the code you are writing.
oke
i passed in client myself
it wasn't in the guide or anything