Code returns error #494
-
My code:
Error:
Sometimes the error:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The error is being caused because the You should check if the Additionally, you can check if the cache property exists before trying to access it.
|
Beta Was this translation helpful? Give feedback.
The error is being caused because the
guild.channels
object is undefined or theguild.channels.cache
object isundefined
. This means that either thefetch()
method is not returning a guild object, or the guild object being returned does not have a channels property.You should check if the
fetch()
method is being passed the correct guild ID, and if the returned guild object has a channels property.Additionally, you can check if the cache property exists before trying to access it.
let guild = await client.guilds.fetch('**guildid**'); if(guild && guild.channels && guild.channels.cache){ let channel = guild.channels.cache.get('**cid**'); if(channel && channel.messages) { channel.messages.f…