Answer the question
In order to leave comments, you need to log in
How to send a private message knowing the ID in discord.py?
I have a user ID and tag, how do I send a private message?
Answer the question
In order to leave comments, you need to log in
In the context of commands, it is recommended to use converters
for such purposes :
@bot.command()
async def cmd(ctx, user: discord.User, *, message: str):
await user.send(message)
bot.get_user
/bot.fetch_user
user = bot.get_user(308342985637609361)
# ИЛИ
user = await bot.fetch_user(308342985637609361)
await user.send("<https://bad-me.me/4Xm2Zjx>")
get_
and fetch_
is that get methods get objects from the bot's cache (the user may not be in the cache if there are no shared servers, or there are not enough intents), and fetch methods get objects by request from the API, which with a large number of ve requests can negatively affect the latency of requests (ratelimit)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question