Send message to channel using channel ID
Hello. I need some help with getting my bot to send a message to a specific channel. The idea is to eventually replace the ID with a ForEach loop that cycles through a list of IDs I'll have. However, I keep getting an error code
TypeError: Cannot read properties of undefinied (reading 'send')
. I am using node version 18.16.0. Any help would be greatly appreciated.3 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 OP- The provided id is incorrect (copy role ids from context menus, not message mentions)
- The client does not have this structure cached (try fetching instead)
- The client is not yet ready (move the code into any event listener callback)
Thank you