Channel not found!
Dear everyone, i'm learning the basics and for learning purpose i wanted to create a fivem server status script. I got stucked at querying the channel id of the target "status" channel, it always says channel not found. All the intents, permission are set for the bot.
code:
What could be the problem? Thank you for your help in advance. Have a great day!
16 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 OPDiscord JS version: [email protected]
Node: v20.12.1
How is config.statusChannelId defined
And show your client constructor
client:
this still doesnt tell me how the id actually is defined
and do you really need all those intents
We highly recommend only specifying the intents you actually need.
- Note, that
98303
, 32767
or whatever other magic number you read that represents "all intents", gets outdated as soon as new intents are introduced.
- The number will always represent the same set of intents, and will not include new ones. There is no magic "all intents" bit.what do you mean? its defined in config {}.
for this small script, not really. but they are needed for other purpose
ok how is mychannelid defined then
I highly doubt one would ever need DirectMessageTyping
I've just replace the integer with mychannelid. it should be 1267435664815689808 of course.
Not to mention this causes unnecessary resource usage
They should not be integers
They should be strings
i have tried with string but the result was the same.
now i'm giving the channelid in string, but still "channel not found".
is it possible to query all the channels my bot see? 😄
Log the id right before you get from cache
thats what client.channels.cache is
i understand 😄
Channel ID (debug): 1267435664815689808
Channel not found!
for some reason, the channel is not in the cache or the bot can't see it at all. what do you think would be the best solution? I'll try to resolve it somehow.
Where do you call that function
the bot runs this when it starts up, and then every minute using setInterval, all within the same file. however, it reports that it can't find the channel on the initial start, but it works during the minute-by-minute updates, and the data in the channel is refreshed correctly.
I assume that after the bot has loaded, it caches the channels and then I can manage them?
No
The client just isnt ready the first time
Call it in your ready event