ChannelNotCached

Error [ChannelNotCached]: Could not find the channel where this message came from in the cache! how to fix this error its showing up in my messageCreate event
19 Replies
d.js toolkit
d.js toolkit12mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
MrMythical
MrMythical12mo ago
Is it a dm?
Aura
Aura12mo ago
Versions: Discord.js v14.11.0 NodeJS v16.20.1 Line
if (!message.channel.permissionsFor(message.guild.members.me).has([PermissionsBitField.Flags.SendMessages]))
return message.author.send({ content: `I am missing \`send messages\` permissions in **${message.channel.name}**.` })
if (!message.channel.permissionsFor(message.guild.members.me).has([PermissionsBitField.Flags.SendMessages]))
return message.author.send({ content: `I am missing \`send messages\` permissions in **${message.channel.name}**.` })
Error:
node:events:491
throw er; // Unhandled 'error' event
^
Error [ChannelNotCached]: Could not find the channel where this message came from in the cache!
at Message.reply (/root/cyber/node_modules/discord.js/src/structures/Message.js:838:46)
at messageCreate.run (/root/cyber/src/events/interactions/messageCreate.js:42:33)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on CyberClient instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21) {
code: 'ChannelNotCached'
}
node:events:491
throw er; // Unhandled 'error' event
^
Error [ChannelNotCached]: Could not find the channel where this message came from in the cache!
at Message.reply (/root/cyber/node_modules/discord.js/src/structures/Message.js:838:46)
at messageCreate.run (/root/cyber/src/events/interactions/messageCreate.js:42:33)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on CyberClient instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21) {
code: 'ChannelNotCached'
}
@Myth 🌈
treble/luna
treble/luna12mo ago
do you have the Guilds intent
Aura
Aura12mo ago
intents: ["Guilds", "GuildVoiceStates", "GuildMessages", "MessageContent", "GuildMessageReactions"]
intents: ["Guilds", "GuildVoiceStates", "GuildMessages", "MessageContent", "GuildMessageReactions"]
Yes @luna🌈
Squid
Squid12mo ago
Are you sure you shared the correct line? This error is being thrown from calling <Message>.reply() according to the error stack, not <User>.send() The erroring line is src/events/interactions/messageCreate.js:42
Aura
Aura12mo ago
I'm sorry
if (!message.channel.permissionsFor(message.guild.members.me).has([PermissionsBitField.Flags.EmbedLinks])) return message.reply({ content: `I am missing \`embed links\` permissions in **${message.channel.name}**.` })
if (!message.channel.permissionsFor(message.guild.members.me).has([PermissionsBitField.Flags.EmbedLinks])) return message.reply({ content: `I am missing \`embed links\` permissions in **${message.channel.name}**.` })
This was the line it was the previous line @Squid
Squid
Squid12mo ago
Can you show your full Client construction?
Aura
Aura12mo ago
const { ClusterClient, getInfo } = require('discord-hybrid-sharding');

class CyberClient extends Client {
constructor(options) {
super({
shardCount: getInfo().TOTAL_SHARDS,
shards: getInfo().SHARD_LIST,
allowedMentions: { parse: ['roles'], repliedUser: false },
intents: ["Guilds", "GuildVoiceStates", "GuildMessages", "MessageContent", "GuildMessageReactions"]

})
this.cluster = new ClusterClient(this);
const { ClusterClient, getInfo } = require('discord-hybrid-sharding');

class CyberClient extends Client {
constructor(options) {
super({
shardCount: getInfo().TOTAL_SHARDS,
shards: getInfo().SHARD_LIST,
allowedMentions: { parse: ['roles'], repliedUser: false },
intents: ["Guilds", "GuildVoiceStates", "GuildMessages", "MessageContent", "GuildMessageReactions"]

})
this.cluster = new ClusterClient(this);
@Squid
treble/luna
treble/luna12mo ago
doesnt seem to be djs related
Aura
Aura12mo ago
How to handle Unknown Interaction error @luna🌈
d.js docs
d.js docs12mo ago
Common causes of DiscordAPIError[10062]: Unknown interaction: - Initial response took more than 3 seconds ➞ defer the response *. - Wrong interaction object inside a collector. * Note: you cannot defer modal or autocomplete value responses
treble/luna
treble/luna12mo ago
and #rules 5
Aura
Aura12mo ago
I'm sorry Alright thanks
const Client = require('./lib/base/CyberClient');
const { token } = require("../config");
const client = new Client();
client.login(token);
const Client = require('./lib/base/CyberClient');
const { token } = require("../config");
const client = new Client();
client.login(token);
Please provide a fix for this !
treble/luna
treble/luna12mo ago
you appear to be using a custom client, not a discord.js one
Squid
Squid12mo ago
@aura.me Do you ever call message.channel.delete() in your project?
Aura
Aura12mo ago
Am not using a custom client am just extending the discord.js client to add some config and define some files Nope but i do use message.delete() not channel.delete
Squid
Squid12mo ago
I don't have a solution, but the problem here is confusing (for anyone else who may try to help): The internal line that throws the error is if (!this.channel) return Promise.reject(new DiscordjsError(ErrorCodes.ChannelNotCached)); from Message#reply(). That means that this.channel is falsy; however, because Message#reply() only gets called by your if statement's condition which relies on message.channel.permissionsFor(...)..., message.channel must be truthy. Therefore, something is causing message.channel to change from truthy to falsy from the time of reaching the if statement to the time that you call message.reply(), which ... feels impossible You can try uninstalling and reinstalling discord.js, but that's all I personally have left
Aura
Aura12mo ago
@squiddleton ohk i will try this