英文:
Check if a message has been deleted in discordjs
问题
我有一个 Discord.js 中的机器人,我正在尝试检查交互回复消息是否已被删除,以避免“未知消息”错误。
英文:
I have a bot in discordjs and I'm trying to check if the interaction.reply message has been deleted or not to avoid "Unknown Message" Errors
答案1
得分: 1
使用try-catch
,您可以捕获错误,如果消息被删除
try {
const message = await interaction.reply('message');
console.log('Message not deleted');
} catch (error) {
console.error('Message deleted');
}
英文:
using a try-catch
you can catch the error if the message was deleted
try {
const message = await interaction.reply('message');
console.log('Message not deleted');
} catch (error) {
console.error('Message deleted');
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论