Estoy tratando de hacer un comando de prohibición que pueda prohibir a alguien usando su ID y funciona muy bien, el problema es que cuando trato de prohibir a un usuario que no está en el servidor (usando su ID) o solo uso 1 dígito, el El comando no funciona y el bot falla. Creo que el problema se debe a la instrucción if, pero no estoy seguro.
Aquí está mi código:
let args = messageArray.slice(1); if(message.content.startsWith(prefix + 'ban')) { let toBan = message.guild.members.cache.get(args[0]) || message.mentions.members.first() || message.guild.members.cache.find(x => x.user.username.toLowerCase() === args.slice(0).join(" ") || x.user.username === args[0]); if(!args) return message.channel.send('You need to mention a user!') if (!message.member.hasPermission("VIEW_AUDIT_LOG")) return message.channel.send("You don't have enough permissions.") if (!message.guild.me.hasPermission("BAN_MEMBERS")) return message.channel.send("I don't have enought permissions.") if(!toBan.bannable) return message.channel.send("I can't ban that user!") if(toBan === message.author) return message.channel.send("No.") if(toBan.roles.highest.position >= message.member.roles.highest.position) return message.channel.send("You can't ban anyone that have a high or same role that you have.") const reason = args[1] || "Undefined"; member.ban(`${toBan}`, { reason: reason }) message.channel.send(`${toBan} Has been banned of the server by ${message.author}!`) }Puede usar GuildMemberManager.ban() , que toma un UserResolvable . Puede ser un User , un GuildMember o incluso simplemente un Snowflake de nieve (ID).
Ejemplo sencillo:
message.guild.members.ban("12345678901234567");