Get a User object from a ping using discord.py

Viewed 190

I want one of the commands for my discord bot to give a specific role to the user mentioned in the command. For example: !giveperm @Bob

In this case Bob would be given a role. However the add_roles() function takes a discord.User object. Is there a way to turn a ping in a string format into a discord.User object. Something like: discord.User(ping="{ping}")

Thank you

1 Answers

This should work.

@bot.command()
async def giveperm(ctx, user: discord.User):
    await ctx.send(user.id)
    #other code
Related