我正在为我的不和谐机器人发出禁止命令,除了一件事之外,一切正常,机器人应该发送给被禁止用户的嵌入没有被发送我遇到了一个 Discord API 问题,这个问题:
<块引用>DiscordAPIError:表单正文无效
这是我的 ban.js
文件:
module.exports = {
name: 'ban',
description: "This command bans a member!",
async execute(message, args) {
const member = message.mentions.users.first();
if(message.member.roles.cache.has("858091311126806538")) {
if(!message.guild.me.hasPermission("BAN_MEMBERS")) {
return message.channel.send(`**${message.author.username}**, I do not have perms to ban someone`)
}
let banReason = args.join(" ").slice(22);
if (!banReason) {
banReason = "None"
}
if (member) {
const memberTarget = message.guild.members.cache.get(member.id);
const Discord = require('discord.js');
const delay = (msec) => new Promise((resolve) => setTimeout(resolve, msec));
const authoRR = message.author.tag;
const banEmbed = new Discord.MessageEmbed()
.setColor('#ff0000')
.setTitle(`You are banned from Anime Club!`)
.setAuthor(`${authoRR}`, `${message.author.displayAvatarURL()}`)
.setThumbnail(member.displayAvatarURL())
.addFields(
{ name: 'Banned User:', value: `${memberTarget}` },
{ name: 'Ban Reason:', value: `${banReason}` },
{ name: ' ', value: `You were **banned** from Anime Club,
please do not try to rejoin the server or beg the owner to unban you`}
)
.setTimestamp()
message.mentions.users.first().send(banEmbed);
await delay(100);
memberTarget.ban({
reason: banReason
})
const Author = message.author;
const BanEmbed = new Discord.MessageEmbed()
.setColor('#ff0000')
.setTitle(`User has been banned!`)
.setThumbnail(member.displayAvatarURL())
.addFields(
{ name: 'Banned User:', value: `${memberTarget}` },
{ name: 'Ban Reason:', value: `${banReason}` },
{ name: 'Banned by:', value: `${Author}` },
)
message.channel.send(BanEmbed);
} else {
return message.reply(`Please mention a member!`);
}
} else return message.reply(`You must be an administrator to unban a member`)
}
}
有人可以帮忙吗?我真的不明白这个问题。
答案 0 :(得分:0)
EmbedFieldData
的 name
属性不能为空。如果字段名称仅包含 whitespace characters,则 Discord 将其视为空。如果您想让内容明显为空,您可以尝试这样的操作。
{
name: '** **',
value: `You were **banned** from Anime Club,
please do not try to rejoin the server or beg the owner to unban you`
}