Bot cannot edit its own messages

With my bot I am trying to make it so that when you press a button it becomes disabled. This fails so I simplified it to just trying to edit it to some basic text to see if I somehow did something wrong but it also doesnt work. On button press I am getting interaction.message and then calling .edit on it, however that fails. Basically when pressing the button im trying to run
interaction.message.edit("test")
interaction.message.edit("test")
and it fails
Error [ChannelNotCached]: Could not find the channel where this message came from in the cache!
Error [ChannelNotCached]: Could not find the channel where this message came from in the cache!
What am I doing wrong? Im doing this in a dm, but ive been able to edit messages in dms from the bot in the past. Any ideas?
14 Replies
d.js toolkit
d.js toolkit2y 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.
KevinWho
KevinWhoOP2y ago
duck
duck2y ago
you'll need the Channel partial to receive the dm channel
With my bot I am trying to make it so that when you press a button it becomes disabled. This fails
in what way does it fail? care to share your code for that?
KevinWho
KevinWhoOP2y ago
Also this buttons thing is a passthrough that I made, yes I made sure it recives the events properly
KevinWho
KevinWhoOP2y ago
oh and this right here is the message its editing, when its pressed It should change to "test"
KevinWho
KevinWhoOP2y ago
Actually yeah adding the channel partials worked. What exactly are partials? I dont remember them being a thing
d.js docs
d.js docs2y ago
guide Popular Topics: Partial Structures read more
KevinWho
KevinWhoOP2y ago
ah, intresting. Its a v13 thing. So its basically a cached version of the message but not all the data?
duck
duck2y ago
in this case it's the channel that's partial, hence requiring the Channel partial rather than the Message partial but yes, it's that the structure is not whole, hence the name 'partial'
KevinWho
KevinWhoOP2y ago
How do I know what is in the partial and what is not? also before v13 it cached everything right? so with no partials enabled it does no caching?
duck
duck2y ago
How do I know what is in the partial and what is not?
as a general rule of thumb, I'd recommend having the Channel partial when working with dms, even if it's not through the messageCreate event beyond that, the most common ways of receiving partial data are through 'update' and 'delete' events and attempting to receive reaction events on uncached messages these events won't emit partial data in the first place without the associated partials enabled interactions however will still emit since interaction.channel is just a getter based on interaction.channelId and is therefore nullable, so the interaction object itself isn't partial
also before v13 it cached everything right? so with no partials enabled it does no caching?
as mentioned on the guide, partials were introduced in v12 I don't really remember how v11 behaved tbh
KevinWho
KevinWhoOP2y ago
you talk about receiving partial data, so its not a cached thing, but something that the discord api sends? Maybe to reduce bandwidth or something?
duck
duck2y ago
you talk about receiving partial data, so its not a cached thing, but something that the discord api sends?
the api is what sends the partial data and the partials client option is just a way for you to control whether you want to handle this partial data I'm not sure what you mean by 'its not a cached thing'
Maybe to reduce bandwidth or something?
there's probably a number of reasons as to why discord doesn't send everything all the time if you want specifics, you'd probably want to ask discord
KevinWho
KevinWhoOP2y ago
Alright it makes sense, I guess it doesnt send events that you extra dont ask for. I thought that it was just the client caching parts of messages and not that they were coming from the api. Alright thanks!
Want results from more Discord servers?
Add your server