I’m making a ban command and I need to check if the target user has administrator permissions. I’ve tried:
const user = message.mentions.users.first(); const userMember = message.guild.members.fetch(user)
But I’m getting an error: TypeError: userMember.hasPermission is not a function
Is there a way to fix this?
Advertisement
Answer
.fetch()
returns a promise so you need to await
the results:
const userMember = await message.guild.members.fetch(user) userMember.hasPermission()
You could also get the member instead of the user from the mentions
:
const member = message.mentions.members.first() member.hasPermission()