gpt4 book ai didi

javascript - 嵌入 : DiscordAPIError: Cannot send an empty message

转载 作者:行者123 更新时间:2023-12-05 09:04:46 30 4
gpt4 key购买 nike

又是我..

好吧:

我正在尝试创建一个命令来警告用户他们加入了错误的服务器,但是当我运行该命令时,我收到无法发送空消息错误..

真的,我们将不胜感激!

const Discord = require("discord.js")

module.exports.run = async (client, message, args, err) => {
const embed = new Discord.MessageEmbed().setTitle('Hey!').setDescription('We think you have our server mistaken. etc etc')
if (!args[0]) return message.reply('Who?', { allowedMentions: { repliedUser: false } });
const member = message.mentions.members.first() || await message.guild.members.fetch(args[0]).catch(e => {
check = true;
return message.reply('Can\'t find specefied member! Provide a valid ID, or mention ig lol.', { allowedMentions: { repliedUser: false } });
});
message.channel.send(embed).catch(err)
message.channel.send(`${member}`)
}

错误:

DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:\Users\stupk\Desktop\Holo\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async RequestHandler.push (C:\Users\stupk\Desktop\Holo\node_modules\discord.js\src\rest\RequestHandler.js:50:14) {
method: 'post',
path: '/channels/843567563648139317/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
},
files: []
}
}

最佳答案

从 discord.js v13 开始,API 支持每条消息最多嵌入 10

所以,而不是:

message.channel.send({ embed: embed })

改为传入嵌入数组:

message.channel.send({ embeds: [embed1, embed2, embed3... embed10] })

当然,您也可以只插入一个嵌入:

message.channel.send({ embeds: [embed] })

变更日志: https://discordjs.guide/additional-info/changes-in-v13.html#sending-messages-embeds-files-etc

您可能还会在其中找到一些额外的东西。

关于javascript - 嵌入 : DiscordAPIError: Cannot send an empty message,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68239927/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com