My ban command checks if a user is bannable then bans them. My kick does the same thing but it actually works. The ban message sends so the user is bannable but doesn't actually get banned. Here's my code
if (memberTarget.bannable) {
if (
message.member.roles.highest.position >
message.guild.members.cache.get(target.id).roles.highest.position
) {
target.ban(reason);
let banReason = new Discord.MessageEmbed()
.setDescription(`**${target.user.tag}** has been banned.`)
.addField("Reason:", `${!reason ? "Unspecified" : `${reason}`}`)
.setFooter(
`banned by ${message.author.tag}`,
"https://cdn.discordapp.com/attachments/375020097431011328/881012463645126686/3dgifmaker15131.gif"
)
.setColor("#000000");
message.reply({ embeds: [banReason] }).catch((err) => {
message.channel.send({ embeds: [banReason] });
});
}
My problem with this is everytime I try to go and kick someone, I get my error:
if (!memberTarget.bannable) {
let lowPerms = new Discord.MessageEmbed()
.setDescription(
`<:role:887134365476335626> I lack the required permission to ban **${target.user.tag}**.`
)
.setColor("#000000");
message.reply({ embeds: [lowPerms] });
}
This happens even why I try to kick someone with no roles and my bot had administrative permissions. The actual error itself:
C:\Users\\Documents\GitHub\omex\node_modules\discord.js\src\managers\GuildBanManager.js:142
if (typeof options !== 'object') throw new TypeError('INVALID_TYPE', 'options', 'object', true);
^
TypeError [INVALID_TYPE]: Supplied options is not an object.
at GuildBanManager.create (C:\Users\\Documents\GitHub\omex\node_modules\discord.js\src\managers\GuildBanManager.js:142:44)
at GuildMemberManager.ban (C:\Users\\Documents\GitHub\omex\node_modules\discord.js\src\managers\GuildMemberManager.js:364:28)
at GuildMember.ban (C:\Users\\Documents\GitHub\omex\node_modules\discord.js\src\structures\GuildMember.js:299:31)
at Object.execute (C:\Users\\Documents\GitHub\omex\commands\ban.js:32:22)
at Client.<anonymous> (C:\Users\\Documents\GitHub\omex\index.js:133:20)
at Client.emit (node:events:394:28)
at MessageCreateAction.handle (C:\Users\\Documents\GitHub\omex\node_modules\discord.js\src\client\actions\MessageCreate.js:23:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\\Documents\GitHub\omex\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\\Documents\GitHub\omex\node_modules\discord.js\src\client\websocket\WebSocketManager.js:345:31)
at WebSocketShard.onPacket (C:\Users\\Documents\GitHub\omex\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22) {
[Symbol(code)]: 'INVALID_TYPE'
}