Discord 嵌入函数不适用于 API 调用

Discord Embed function not working with API call

提问人:C-Bertram 提问时间:11/12/2023 最后编辑:C-Bertram 更新时间:11/13/2023 访问量:16

问:

我在 discord.js 中的嵌入函数出现问题,我间歇性地收到错误。

DiscordAPIError[10062]: Unknown interaction

我已经拿出一堆代码来尝试识别问题。下面的代码是一个简化版本,仍然给我带来问题。

如果我拿出 API 调用,它就可以工作了,而且它是间歇性的,这让我相信这可能与导致嵌入失败的 API 结果的速度有关?

有什么建议吗?

client.on('interactionCreate', async (interaction) => {
  if (!interaction.isCommand()) return;
  console.log(interaction.commandName)

  const embed = new EmbedBuilder();
  embed.setColor('#0099ff')
  embed.setURL('https://top.gg/bot/951349733211930654')
  embed.setAuthor({ name: 'WINGMAN | Apex Legends', iconURL: 'https://apex-resources.s3.eu-west-1.amazonaws.com/apex-logo.png', url: 'https://top.gg/bot/951349733211930654' })


  id = interaction.id

  if (interaction.commandName === 'stats') {
    https.get(apilink, (resp) => {
      let data = '';
      // A chunk of data has been received.
      resp.on('data', (chunk) => {
        data += chunk;
      });
      // The whole response has been received. Print out the result.
      resp.on('end', () => {
        //console.log(JSON.parse(data));
        j_data = JSON.parse(data)
        console.log(j_data)

        embed.setTitle("Header")
        embed.setDescription("**Status: ** ")

        interaction.reply({ embeds: [embed] });
      });

    }).on("error", (err) => {
      console.log("Error: " + err.message);
    });
  }
}
节点.js 不和谐.js

评论

0赞 Zsolt Meszaros 11/12/2023
从何而来?interaction
0赞 C-Bertram 11/13/2023
我在原始问题中添加了更多代码。这些信息够吗?

答: 暂无答案