Ben
Ben
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Ben on 2/16/2023 in #djs-questions
Bot stays offline/unresponsive after reconnect
5 replies
DIAdiscord.js - Imagine an app
Created by Ben on 2/13/2023 in #djs-questions
Can't edit a message in DM sent by bot
- discord.js@14.7.1 and node version v18.10.0 I'm trying to edit a message in DM sent by the bot via a button press. the button event looks like the following (skipped parts not relevant for this question):
async function refreshReminder(interaction: ButtonInteraction<CacheType>) {
interaction.message.edit({ embeds: [reminderEmbed] });
interaction.deferUpdate();
}
async function refreshReminder(interaction: ButtonInteraction<CacheType>) {
interaction.message.edit({ embeds: [reminderEmbed] });
interaction.deferUpdate();
}
This results in the following error:
if (!this.channel) return Promise.reject(new DiscordjsError(ErrorCodes.ChannelNotCached));
^
Error [ChannelNotCached]: Could not find the channel where this message came from in the cache!
at Message.edit (P:\Documents\Programming Projects\Chronos\Chronos\node_modules\discord.js\src\structures\Message.js:691:46)
at refreshReminder (P:\Documents\Programming Projects\Chronos\Chronos\src\index.ts:312:23)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (P:\Documents\Programming Projects\Chronos\Chronos\src\index.ts:146:4) {
code: 'ChannelNotCached'
}
error Command failed with exit code 1.
if (!this.channel) return Promise.reject(new DiscordjsError(ErrorCodes.ChannelNotCached));
^
Error [ChannelNotCached]: Could not find the channel where this message came from in the cache!
at Message.edit (P:\Documents\Programming Projects\Chronos\Chronos\node_modules\discord.js\src\structures\Message.js:691:46)
at refreshReminder (P:\Documents\Programming Projects\Chronos\Chronos\src\index.ts:312:23)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (P:\Documents\Programming Projects\Chronos\Chronos\src\index.ts:146:4) {
code: 'ChannelNotCached'
}
error Command failed with exit code 1.
I also tried a solution i found on stackoverflow from 2021 that looks like the following:
const user = client.users.cache.get(userId);
user?.dmChannel?.messages.fetch(messageId).then(dmMessage => {
dmMessage.edit('edited!');
});
interaction.deferUpdate();
const user = client.users.cache.get(userId);
user?.dmChannel?.messages.fetch(messageId).then(dmMessage => {
dmMessage.edit('edited!');
});
interaction.deferUpdate();
however, this results in the dmChannel property being null and thus not working either
4 replies