Unable to send an embed
Hi, my code is practically the one that is included in the guide. I added a command which exports, during the execute phase an embed. When I try to post it into a specific channel from the index.js file there is an error I can't fix
There is a document that has both the addAnime.js file and the index.js file along with the error I get
14 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPread the guide again. the execute function is there to use when the command runs. also
module.exports
cannot be used outside of global scopeHow can I get embed data from a command and send it to a specific channel using the index.js file?
you dont code the command in index.js
the code should be in your execute file
How can i send it to a specific channel from the execute file
Found out that doesn't really work and tried into the index.js file
pass the client to the function
now it works but cant gather the information to send
now you only have interaction
how do i do that
pass client in there too
i recommend you freshen up on your js basics #resources
but tldr
again this is quite basic javascript
you should freshen up
Thanks
TypeError: Cannot read properties of undefined (reading 'channels')
at Object.execute (C:\Users\Andrea Pavesi\discord-bot\commands\utility\addAnime.js:46:20)
at Client.<anonymous> (C:\Users\Andrea Pavesi\discord-bot\index.js:41:17)
at Client.emit (node:events:518:28)
at InteractionCreateAction.handle (C:\Users\Andrea Pavesi\discord-bot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\Andrea Pavesi\discord-bot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\Andrea Pavesi\discord-bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (C:\Users\Andrea Pavesi\discord-bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:232:12)
at WebSocketManager.emit (C:\Users\Andrea Pavesi\discord-bot\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
at WebSocketShard.<anonymous> (C:\Users\Andrea Pavesi\discord-bot\node_modules@discordjs\ws\dist\index.js:1190:51)
at WebSocketShard.emit (C:\Users\Andrea Pavesi\discord-bot\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
tag suggestion for @paves:
The order of function parameters must match between definition and function call.
- mismatch! you pass an interaction where the client is expected
- mismatch! you pass the client where an interaction is expected
in your case, i dont think you pass the client
in your main file
thank you it works