#DM user with known ID

1 messages · Page 1 of 1 (latest)

ashen echo
#

i'm trying to DM a user with a known ID, if you could give a code example that would help me understand.

brisk urchinBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

proven hemlock
#

await bot.fetch_user().send()

ashen echo
#

Where do I specify the content of the message and the users id?

night flicker
#

it's the same as ctx.send(). fetch_user(<id here>) gets a user object from the id

ashen echo
#

I get this error

File "/root/botv2.py", line 46, in poke_function
    await ctx.send("test").fetch_user(187867424207405056)
AttributeError: 'coroutine' object has no attribute 'fetch_user'
night flicker
#

you misunderstood what i said.

await bot.fetch_user(id) returns a User object which has the asyncronous send() method. The arguments are the same as ctx.send().

#

also you can't really chain asyncronous functions

#

so altogether it would be

user = await bot.fetch_user(1234)

await user.send(content="Hello World")