繁体   English   中英

我收到此错误 DiscordAPIError: Invalid Form Body

[英]I get this error DiscordAPIError: Invalid Form Body

我正在为我的不和谐机器人发出禁止命令,除了一件事之外,一切都在工作,机器人应该发送给被禁止用户的嵌入没有被发送我遇到了一个 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`)
    }
}

任何人都可以帮忙吗? 我真的不明白这个问题。

EmbedFieldDataname属性不能为空。 如果字段名称仅包含空白字符,则 Discord 将其视为空。 如果你想让内容明显为空,你可以尝试这样的事情。

{
    name: '** **',
    value: `You were **banned** from Anime Club,
            please do not try to rejoin the server or beg the owner to unban you`
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM