Skip to content
Advertisement

Ho to get exactly id from ping discord py

I want to create a command using id from pinged user and the return id like that : <@696986678887317556> and i want it : 696986678887317556, so i have coding this :

@bot.command()
@commands.has_permissions(administrator=True)
async def autp(ctx, name):
    print(name)
    name = str(name)
    nachar = ["@", "<", ">"]
    for x in nachar:
        id = name.replace(x, '')
    print(id)

And the result are this : <@696986678887317556 how i can code it pls 😭

Advertisement

Answer

The mentioned user will be in ctx.message.mentions so loop that or get the first item in the list, and you will find the first mention with also the id that doesen’t contained special characters.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement