问题:DiscordAPI错误:未知消息[1008]



我现在正试图制作一个清除命令(遵循recolx针对DJS v13的清除命令教程(,但我一直收到一个DiscordAPI错误。

该命令只工作一次,但它并没有像预期的那样使用嵌入进行回复,然后与其他所有命令一起崩溃。经过一段时间后,它确实再次发挥作用,然后循环一次又一次地重复。

我已经确保我有正确的意图(我确实这样做了(等等,但似乎什么都不起作用。。。我不知道到底是什么原因导致了这个错误。任何愿意帮忙的人都是在帮我一个忙。

哦,下面是purge.js的代码和有问题的错误。

const { MessageEmbed } = require("discord.js");
const ms = require("ms");
module.exports = {
name: "purge",
description: "Purges messages",
userPermissions: ["MANAGE_MESSAGES"],
options: [
{
name: "amount",
description: "Amount of messages to purge",
type: "INTEGER",
required: true,
},
],
run: async (client, interaction) => {
const amount = interaction.options.getInteger("amount");
const limitEmbed = new MessageEmbed()
.setColor("#2F3136")
.setTitle("You may only purge 100 messages at a time!")
.setFooter({ text: "Error: Limit Reached" })
if (amount > 100) 
return interaction.followUp({ 
embeds: 
[limitEmbed], 
});
const messages = await interaction.channel.messages.fetch({ 
limit: amount + 1,
});
const filtered = messages.filter(
(msg) => Date.now() - msg.createdTimestamp < ms("14 days")
);
await interaction.channel.bulkDelete(filtered)
const successEmbed = new MessageEmbed()
.setColor("#2F3136")
.setTitle(`Successfully purged ${filtered.size - 1} messages!`)
.setFooter({ text: "Action Successfully Performed" })
interaction.followUp({ 
embeds: 
[successEmbed],
});
},
};

错误:

DiscordAPIError: Unknown Message
at RequestHandler.execute (C:UsersadminDesktopTonkotsunode_modulesdiscord.jssrcrestRequestHandler.js:350:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RequestHandler.push (C:UsersadminDesktopTonkotsunode_modulesdiscord.jssrcrestRequestHandler.js:51:14)
at async InteractionWebhook.send (C:UsersadminDesktopTonkotsunode_modulesdiscord.jssrcstructuresWebhook.js:196:15) {
method: 'post',
path: '/webhooks/950050048618688572/aW50ZXJhY3Rpb246OTk5MjYyNTIyMTc3NzQ5MDAzOmhGaUJVQkF6YjduVUlZNTJsT1MwV254T2FYdEJiaUNMWDdwUWloYzhyNnJudERLMHhxak96RTlkTmpDQW5sdEhONnhKSGkyZkdlQndmWGJQSFM0dk52bGduZ3hBTlE3S3g4R2JBRWFRdDNEbmtrb3Z6a0hpVk8yU2hIYllyemhm?wait=true',
code: 10008,
httpStatus: 404,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [
{
title: 'Successfully purged 3 messages!',
type: 'rich',
description: null,
url: null,
timestamp: 0,
color: 3092790,
fields: [],
thumbnail: null,
image: null,
author: null,
footer: {
text: 'Action Successfully Performed',
icon_url: undefined
}
}
],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}

您应该使用interaction.reply(...)而不是interaction.followUp(...),当您已经回复消息并希望继续回复交互时,会使用followUp。因此,如果你试图在尚未回复的互动中使用它,它会抛出一个错误。

最新更新