L
L
LimeGeeg2022-01-10 12:01:00
Python
LimeGeeg, 2022-01-10 12:01:00

How to make the bot wait for the user to attach a file, and then save it to discord.py?

You need to make sure that the bot waits for 60 seconds until the user sends a picture. After that, the bot must save it to the root folder with the file. discord.py library

for attach in mag5.attachments:
          await attach.save(f"./{message.author.id}.png")


Here is the code for saving the file, it will work if embedded in the on_message structure. But I need to make the bot wait until the user sends the file, and then this part of the code will do its job, and I don’t know how to do it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
y7o4ka, 2022-01-30
@y7o4ka

d.py has bot.wait_for created specifically for this.
If you need longer waits that can, for example, survive a bot restart, look at the on_message event

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question