there is this code:

async def g_token(ctx, us):
    loc= os.getcwd()
    author= ctx.message.author
    a= str(author.id)
    memid= us[3:21]
    user= bot.get_user("676013712917659648")
    await user.send('TEST!')

and it fully works!

but if insteaduser= bot.get_user("676013712917659648")insertuser= bot.get_user(memid)it does not send a message to pm

If someone doesn't understand,memid= us[3:21]from <@!id> does id

adding a debug line:print(us, type(us))received this response:<@!676013712917659648> <class 'str'>

and by adding this debug line:print(memid)got the answer:676013712917659648

and if you try to outputuserit will answer:None!

PS: There is a person with this id on the server

I suspect that the problem is in the data type, but I do not know how to solve this problem

Selasi2022-02-05 12:39:13

Is us exactly what you expect? Try to add print(us, type(us)) at the very beginning of the function and add to the question what such a command will output.

Xander2022-02-05 12:39:13

yes, I checked before, but added to the question what this command outputs

Selasi2022-02-05 12:39:13