#Help with banning member from command

17 messages · Page 1 of 1 (latest)

torn stirrup
#

I am running into the error (displayed in the image) whenever I run my ban command. Here is the code for the ban command: ```js
const guild = client.guilds.cache.get("940438220959789097");

            const user = interaction.options.getMember("user");
            const reason = interaction.options.getString("reason");

            if(user.bannable){
                guild.members.ban(user);
            } else {
                interaction.reply({
                    content: `${user.tag} is not Bannable!`,
                    ephemeral: true
                })
            }
twilit hatchBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

torn stirrup
#

(sorry about the code not being formatted correctly, Discord bugged)

torn stirrup
torn stirrup
#

user is set to a required option in the command

slim crow
#

user is a GuildMember

use user.user.tag, and maybe even rename user to something more accurate, like member

torn stirrup
#

oh

#

Thanks!

#

🙂

pine pelican
#

Just to complement

torn stirrup
twilit hatchBOT
#

Despite sounding similar there is a distinct difference between users and members in Discord:
User: global Discord user data (global avatar, username, tag, id)
GuildMember: user data associated to a guild (guild, nickname, roles, voice, guild avatar, etc.)
• Conversion: User ➞ GuildMember | GuildMember ➞ User

torn stirrup
#

I didn't notice that the interaction option would return a GuildMember

#

thats all