本文介紹了Discord.js 禁止命令中的無效表單正文的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
所以,我一直在嘗試發出禁令命令.我基本上在踢命令上使用了相同的系統,但在這里它不起作用,只是給了我一個錯誤.我很困惑,因為在錯誤中它沒有顯示一行代碼或其他東西.
我的命令/代碼:
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")
}
}
}
錯誤:
(node:13896) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
DICT_TYPE_CONVERT: Only dictionaries may be used in a DictType
推薦答案
這很容易解決,你所要做的就是以正確的方式將適量的參數傳遞給 .ban
功能.
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({ days: 7, reason: 'your reason here' })
https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=ban
這篇關于Discord.js 禁止命令中的無效表單正文的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!