Bot 工作正常,我不时更新以进行一些新的更改,当它工作正常但它一直崩溃时,我重做我所做的一切。
代码:
module.exports = {
name: 'vouch',
description: "this is a vouch command!",
execute(message, args, Discord) {
const client = message.client;
const newEmbed = new Discord.MessageEmbed()
message.channel.send(newEmbed);
if (message.member.roles.cache.has('768903864782553108')) {
const targetID = message.mentions.users.first();
return message.channel.send(new Discord.MessageEmbed()
//.setTitle
.setDescription(`?You have vouched for **${targetID}**.`)
.setColor('GREEN')
.setFooter(client.user.username, client.user.displayAvatarURL())
.setAuthor(message.author.tag, message.author.displayAvatarURL())
.setTimestamp()
.setFooter('Bot was programmed by ~', 'https://i.gyazo.com/04b40914f14d5dba8aebb532ed3e80f3.png')
)
}
}
}
错误:
throw new DiscordAPIError(request.path, data, request.method, res.status); ^
DiscordAPIError:表单正文无效 embed.description:此字段是必需的 在 RequestHandler.execute (C:\Users~\Desktop\Discordbot\node_modules\discord.js\src\rest\RequestHandler.js:154:13) 在 processTicksAndRejections (node:internal/process/task_queues:96:5) 在异步 RequestHandler.push (C:\Users~\Desktop\Discordbot\node_modules\discord.js\src\rest\RequestHandler.js:39:14) { 方法:'发布', 路径:'/channels/683675132677718107/messages', 代码:50035, http状态:400 }
答案 0 :(得分:0)
你可以简单地这样做:
module.exports = {
name: 'vouch',
description: "this is a vouch command!",
execute(message, args, Discord) {
if (message.member.roles.cache.has('768903864782553108')) {
const targetID = message.mentions.users.first();
const newEmbed = new Discord.MessageEmbed()
//.setTitle
.setDescription(`?You have vouched for **${targetID}**.`)
.setColor('GREEN')
.setFooter(client.user.username, client.user.displayAvatarURL())
.setAuthor(message.author.tag, message.author.displayAvatarURL())
.setTimestamp()
.setFooter('Bot was programmed by ~', 'https://i.gyazo.com/04b40914f14d5dba8aebb532ed3e80f3.png')
message.channel.send(newEmbed)
}
}
}
编辑:作为旁注,错误起源于您调用新嵌入但没有为其提供任何值的地方。
const newEmbed = new Discord.MessageEmbed()
message.channel.send(newEmbed);