【发布时间】:2021-08-10 20:58:02
【问题描述】:
所以基本上,我正在尝试从 1 个频道获取嵌入,然后将其发送到另一个频道,但它给出了一个错误,说明有关空消息的内容。
完全错误:
Received 1 messages
/home/bot/node_modules/discord.js/src/rest/RequestHandler.js:298
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (/home/bot/node_modules/discord.js/src/rest/RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/bot/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
at async TextChannel.send (/home/bot/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:171:15) {
method: 'post',
path: '/channels/874619472902774845/messages',
code: 50006,
httpStatus: 400,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
这是我的机器人脚本:
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });;
client.on('ready', () => {
const channel1 = client.channels.cache.get("791100523246911499");
const logchannel1 = client.channels.cache.get("874619472902774845");
channel1.messages.fetch({ limit: 1 }).then(messages => {
console.log(`Received ${messages.size} messages`);
//Iterate through the messages here with the variable "messages".
messages.forEach(message => {
logchannel1.send(message.embeds);
})
})
我希望了解 discord.js 的人可以帮助我解决这个难题。
感谢阅读 问候,臭名昭著。
【问题讨论】:
标签: discord discord.js