Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
33
rated 0 times [  39] [ 6]  / answers: 1 / hits: 6479  / 4 Years ago, sat, october 10, 2020, 12:00:00

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

More From » discord

 Answers
8

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


[#2517] Tuesday, October 6, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alorac

Total Points: 262
Total Questions: 82
Total Answers: 97

Location: Libya
Member since Mon, Dec 7, 2020
4 Years ago
alorac questions
Tue, Sep 22, 20, 00:00, 4 Years ago
Wed, Jul 1, 20, 00:00, 4 Years ago
Wed, Jun 3, 20, 00:00, 4 Years ago
Sun, May 17, 20, 00:00, 4 Years ago
Wed, Mar 4, 20, 00:00, 4 Years ago
;