How to find a discord.js user’s permissions from a message mention?

Tags: , , ,

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?


.fetch() returns a promise so you need to await the results:

const userMember = await message.guild.members.fetch(user)

You could also get the member instead of the user from the mentions:

const member = message.mentions.members.first()

Source: stackoverflow