我目前正在尝试发出一个清除命令(遵循reconlx的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:\Users\admin\Desktop\Tonkotsu\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RequestHandler.push (C:\Users\admin\Desktop\Tonkotsu\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async InteractionWebhook.send (C:\Users\admin\Desktop\Tonkotsu\node_modules\discord.js\src\structures\Webhook.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: []
}
}
发布于 2022-07-20 13:52:31
您应该使用interaction.reply(...)
而不是interaction.followUp(...)
,当您已经回复消息并希望继续响应交互时使用followUp
。因此,如果您试图在尚未被回复的交互中使用它,则会抛出一个错误。
https://stackoverflow.com/questions/73050241
复制相似问题