Reputation: 21
I want to make my bot download and save locally the attachments sent in the command (
is it possible because the only thing I could find is this and it doesn't work as I wanted:
@client.command()
async def hello(ctx):
files = []
for attachment in ctx.message.attachments:
fp = BytesIO()
await attachment.save(fp)
Upvotes: 2
Views: 3390
Reputation: 642
dont use BytesIO as that's meant to be use in memory, just add the filename you wish
@client.command()
async def hello(ctx):
files = []
for attachment in ctx.message.attachments:
# fp = BytesIO()
await attachment.save(attachment.filename)
In this case i used the same filename as the attachment.
Upvotes: 3