首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >问题: DiscordAPIError:未知消息[10008]

问题: DiscordAPIError:未知消息[10008]
EN

Stack Overflow用户
提问于 2022-07-20 10:45:03
回答 1查看 467关注 0票数 0

我目前正在尝试发出一个清除命令(遵循reconlx的DJS v13的清除命令教程),并且我一直收到一个DiscordAPI错误。

然而,该命令只工作一次,但它不会像预期的那样使用嵌入式的响应,然后会与所有其他命令一起崩溃。在一段时间之后,它确实会再次发挥作用,然后循环会一次又一次地重复。

我已经确定我有正确的意图(我是这样做的),但似乎什么都没有.我不知道是什么导致了这个错误。任何愿意帮忙的人都是在帮我的忙。

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

代码语言:javascript
运行
复制
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],
        });
    },
};

错误:

代码语言:javascript
运行
复制
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: []
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-20 13:52:31

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73050241

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档