payload.getJSON 在通过 webhook 发送嵌入时不是函数

payload.getJSON is not a function when sending embed through webhook

正在尝试制作一个基本的 webhook 来发送嵌入。发送常规文本字符串工作正常但尝试发送以下嵌入:

hook.send({
  embeds: [new Discord.MessageEmbed()
    .setDescription(`${interaction.user.username} used ${interaction.commandName}`)
    .addFields(
      { name: "User ID", value: interaction.user.id, inline: true },
      { name: "Guild ID", value: `${interaction.guild ? interaction.guild.name : "DM"}`, inline: true },
    )
    .setColor("BLACK")
  ]
});

导致以下错误:

[ERROR] Unhandled promise rejection: payload.getJSON is not a function.
TypeError: payload.getJSON is not a function
    at Webhook.send (C:\Users\user\Documents\GitHub\bot\node_modules\discord-webhook-node\src\classes\webhook.js:56:28)
    at Client.<anonymous> (C:\Users\user\Documents\GitHub\bot\Events\Interaction Create\interactionCreate.js:116:20)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

我认为这不是给您带来问题的正确代码,我刚刚在基本的 discord bot 中编写了代码并且它可以工作。

const { Client, Intents, WebhookClient, MessageEmbed } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

const hook = new WebhookClient({ url: 'https://discord.com/api/webhooks/ID/TOKEN' })

client.on('ready', () => {
    console.log(`Logged in as ${client.user.tag}!`);
});

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

    if (interaction.commandName === 'ping') {
        hook.send({
            embeds: [new MessageEmbed()
                .setDescription(`${interaction.user.username} used ${interaction.commandName}`)
                .addFields(
                    { name: "User ID", value: interaction.user.id, inline: true },
                    { name: "Guild ID", value: `${interaction.guild ? interaction.guild.name : "DM"}`, inline: true },
                )
                .setColor("BLACK")
            ]
        });
    }
});

client.login('TOKEN');

这是我用来让它工作的代码,如果你再看一下你的代码,我不认为问题出在这段代码上。