I
I
Igor Gafarchik2020-05-12 13:51:57
Python
Igor Gafarchik, 2020-05-12 13:51:57

Discord.py private messages by id?

There is a discord server and it has a bot written in python.
It is necessary that the bot send a private message to the admin when entering the command.

async def test(ctx):
    await ctx.author.send('test')

how to do the same with only user id?
And is it even possible?
async def test(ctx):
   await ctx.idadmin.send('test')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Mukhin, 2021-03-16
@SladkayaDoza

The code is not written correctly, read the discord.py documentation
Link: https://discordpy.readthedocs.io/en/latest/api.html
code that can function:

async def test(ctx, *, user_id: int):
    user = await Client.fetch_user(user_id=user_id)
    await user.send('test')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question