Answer the question
In order to leave comments, you need to log in
Is there any way to resend the image via discord.py that the user submitted?
Is there any way to resend the image via discord.py that the user submitted?
For example, I sent a picture to a bot, and he resent it to another user in private messages. Please help with code
Answer the question
In order to leave comments, you need to log in
Write this code in the on_message function:
if message.attachments:
files = []
for attachment in message.attachments:
files.append(await attachment.to_file())
if files:
user = await bot.fetch_user(user_id) # получение пользователя
dm = await user.create_dm() # получение лс
await dm.send(files=files)
if message.attachments:
files = []
for attachment in message.attachments:
try:
if attachment.content_type.startswith("image/"):
files.append(await attachment.to_file())
except:
continue
if files:
user = await bot.fetch_user(user_id) # получение пользователя
dm = await user.create_dm() # получение лс
await dm.send(files=files)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question