MatheX
MatheX
DIAdiscord.js - Imagine an app
Created by MatheX on 4/30/2025 in #djs-questions
message.edit is not a function
I'm developing a simple Discord bot for my classmates to manage homework assignments. The bot sends homework details as embeds. However, when I attempt to edit an existing homework embed using a button interaction and modal, I encounter the following error:​ /home/matt/School/homeworkBot/responses/edit.js:84 await message.edit({embeds: [updatedEmbed], components: message.components}); ^ TypeError: message.edit is not a function at Statement.<anonymous> (/home/matt/School/homeworkBot/responses/edit.js:84:39) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Node.js v18.19.0 Code Snippet:
const message = await channel.messages.fetch(row[0].message_id, { force: true });
console.log(message);
//outputs Collection(1) [Map] {
// '1367168748129357935' => <ref *1> Message {
// channelId: '1366858248614969465',
// guildId: '1366489027154284604',
// id: '1367168748129357935',
// ETC, the entire object seems fine
await message.edit({embeds: [updatedEmbed], components: message.components});
await interaction.reply({
content: ':white_check_mark: Úkol byl úspěšně upraven.',
ephemeral: true,
});
const message = await channel.messages.fetch(row[0].message_id, { force: true });
console.log(message);
//outputs Collection(1) [Map] {
// '1367168748129357935' => <ref *1> Message {
// channelId: '1366858248614969465',
// guildId: '1366489027154284604',
// id: '1367168748129357935',
// ETC, the entire object seems fine
await message.edit({embeds: [updatedEmbed], components: message.components});
await interaction.reply({
content: ':white_check_mark: Úkol byl úspěšně upraven.',
ephemeral: true,
});
Additional Information: The message_id is retrieved from a database and corresponds to a message previously sent by the bot. The bot has Administrator permissions. The console.log(message); line outputs a valid Message object, indicating that the message is successfully fetched.​ Troubleshooting Steps Taken: Verified that the message is sent by the bot. Confirmed that channel is a valid TextChannel instance. Ensured that updatedEmbed is a properly constructed Embed object. Checked that message.components is an array of MessageActionRow components.​ Request: I'm seeking assistance in identifying why message.edit is not recognized as a function, despite the message object appearing valid. Any insights or suggestions would be greatly appreciated.
5 replies