[英]Invalid Form Body in Discord.js ban command
So, i have been trying to make a ban command.所以,我一直在尝试发出禁令命令。 I basically used the same system on a kick command, but here it didnt work and just gave me an error.
我基本上在踢命令上使用了相同的系统,但在这里它不起作用,只是给了我一个错误。 I am confused since in the error it doesnt display a line of code or something.
我很困惑,因为在错误中它没有显示一行代码或其他东西。
My Command / Code:我的命令/代码:
module.exports = {
name: 'ban',
description: "Ban Command.",
execute(msg, args){
const Discord = require('discord.js')
const Embeds = require('./../embed')
let perms = msg.member.permissions
let has_kick = perms.has("BAN_MEMBERS")
if (has_kick === true) {
const toban = msg.mentions.members.first()
delete args[0]
var string = args.join(' ')
Embeds.error(toban, `You have been banned from ${msg.guild.name} by the user ${msg.author} with the reason ${string}`)
setTimeout(function(){
try {
toban.ban(`was banned by ${msg.author} for: ${string}`)
Embeds.kicked(msg.channel, `${toban} has been banned by ${msg.author} from the server with the following reason: ${string}`, `Banned User from the server`)
} catch {
Embeds.error(msg.channel, `I dont have permissions to ban ${toban} `, "Error")
}
}, 1000);
} else {
const toban = msg.mentions.members.first()
Embeds.error(msg.channel, `You dont have permissions to Ban ${toban} `, "Error")
}
}
}
The Error:错误:
(node:13896) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
DICT_TYPE_CONVERT: Only dictionaries may be used in a DictType
this is pretty easy to solve, all you have to to is pass the right amount of Parameters in the right way to the .ban
function.这很容易解决,您所
.ban
就是以正确的方式将适量的参数传递给.ban
函数。
.ban({ days: 7, reason: 'your reason here' })
https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=ban https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=ban
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.