UNHANDLED_REJECTION: DiscordAPIError: Unknown Message

Hello, I have some issues about my bot. To explain where the errors come from is when I delete RulesMessage even if it deletes correctly and send the other embed (sorry for mistakes in my grammar) Here the part of the code :
const filter_one = (interaction) => interaction.customId === 'b-welcome' && interaction.user.id === member.user.id ;
const collector_one = welcomeChannel.threads.cache.find(x => x.name === thread_title).createMessageComponentCollector({ filter_one, time: 999999999 });


collector_one.on('collect', async (interaction) => {
await interaction.deferUpdate();
await welcomeMessage.delete();

const rules_embed = new MessageEmbed()
.setColor("BLACK")
.setDescription(skedDB.step_one.rules_server.titre + "\n" + skedDB.step_one.rules_server.citations_txt )
.setImage(skedDB.step_one.rules_server.attachment)

const rules_Button = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('first-step')
.setLabel("Suivant")
.setStyle('PRIMARY'),
);

const RulesMessage = await welcomeChannel.threads.cache.find(x => x.name === thread_title).send({ embeds: [rules_embed], components: [rules_Button] });

// ------------------2EME ETAPE DU GUIDE --------------------

const filter_two = (interaction) => interaction.customId === 'first-step' && interaction.user.id === member.user.id ;
const collector_two = welcomeChannel.threads.cache.find(x => x.name === thread_title).createMessageComponentCollector({ filter_two, time: 999999999 });

collector_two.on('collect', async (interaction) => {
// await interaction.deferUpdate();
//await RulesMessage.delete();

const channels_embed = new MessageEmbed()
.setColor("BLACK")
.setDescription(skedDB.step_two.rules_server.titre + "\n" + skedDB.step_two.rules_server.citations_txt )
.setImage(skedDB.step_two.rules_server.attachment)

const Channels_Button = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('snd-help')
.setLabel("Aide moi!")
.setStyle('DANGER'),

new MessageButton()
.setCustomId('snd-step')
.setLabel("On passe")
.setStyle('SUCCESS'),
);
//const ChannelMessage =
await welcomeChannel.threads.cache.find(x => x.name === thread_title).send({ embeds: [channels_embed], components: [Channels_Button] }).then(async (RulesDelete) => {
try {
await RulesMessage.delete();
} catch (error) {
console.log('Erreur sur la suppression de RulesMessage:', error);
}
});

});

});
const filter_one = (interaction) => interaction.customId === 'b-welcome' && interaction.user.id === member.user.id ;
const collector_one = welcomeChannel.threads.cache.find(x => x.name === thread_title).createMessageComponentCollector({ filter_one, time: 999999999 });


collector_one.on('collect', async (interaction) => {
await interaction.deferUpdate();
await welcomeMessage.delete();

const rules_embed = new MessageEmbed()
.setColor("BLACK")
.setDescription(skedDB.step_one.rules_server.titre + "\n" + skedDB.step_one.rules_server.citations_txt )
.setImage(skedDB.step_one.rules_server.attachment)

const rules_Button = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('first-step')
.setLabel("Suivant")
.setStyle('PRIMARY'),
);

const RulesMessage = await welcomeChannel.threads.cache.find(x => x.name === thread_title).send({ embeds: [rules_embed], components: [rules_Button] });

// ------------------2EME ETAPE DU GUIDE --------------------

const filter_two = (interaction) => interaction.customId === 'first-step' && interaction.user.id === member.user.id ;
const collector_two = welcomeChannel.threads.cache.find(x => x.name === thread_title).createMessageComponentCollector({ filter_two, time: 999999999 });

collector_two.on('collect', async (interaction) => {
// await interaction.deferUpdate();
//await RulesMessage.delete();

const channels_embed = new MessageEmbed()
.setColor("BLACK")
.setDescription(skedDB.step_two.rules_server.titre + "\n" + skedDB.step_two.rules_server.citations_txt )
.setImage(skedDB.step_two.rules_server.attachment)

const Channels_Button = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('snd-help')
.setLabel("Aide moi!")
.setStyle('DANGER'),

new MessageButton()
.setCustomId('snd-step')
.setLabel("On passe")
.setStyle('SUCCESS'),
);
//const ChannelMessage =
await welcomeChannel.threads.cache.find(x => x.name === thread_title).send({ embeds: [channels_embed], components: [Channels_Button] }).then(async (RulesDelete) => {
try {
await RulesMessage.delete();
} catch (error) {
console.log('Erreur sur la suppression de RulesMessage:', error);
}
});

});

});
4 Replies
d.js toolkit
d.js toolkit17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Yoshi
YoshiOP17mo ago
I did put a part of my code because it's the exact zone where my code put that error, the rest is correct. I want that my code : - delete RulesMessage after clicking on the button called "Suivant" (next) - Send the channels embed (i did put button but still not finished the code bc if it doesn't work here, then after it will not work too as I want to repeat the code for other embed) Where exactly ? Yes, I do know what it is Wait, but I did put a .catch for the RulesMessage.delete no ? Or you mean after .then ... .catch ? The full error I have is in the title It happens only when I click on "Suivant" after RulesMessage
Yoshi
YoshiOP17mo ago
Yoshi
YoshiOP17mo ago
Oh yeah, it seems logic, how can I make my code delete welcome message and then collect without trying to delete it again ? Yeah, in fact I don't want to do pagination so it doesn't write "edited" so I delete the message after sending a new one with other buttons I'm not good at boolean mhh.. Do you need my entire code ? I found a way to make it work without problem, thank you again !
Want results from more Discord servers?
Add your server