Reputation: 13498
I am trying to get a discord bot to be able to upload all images from a folder when a user types 'uploadAll'. The code is:
def get_image(path):
image_list = []
for filename in glob.glob(path): #appends opened images from folder
im = Image.open(filename) #into list image_list and returns it
image_list.append(im)
return image_list
async def iter_image(path): #uploads images in the list
for i in get_image(path):
client.send_file(discord.Object(id='SERVER_ID'),i)
@client.command(pass_context=True)
async def uploadAll(self): #Should trigger above method
await iter_image('PATH_TO_FOLDER')
The last function results in: TypeError: object NoneType can't be used in 'await' expression. I can't await iter_image because it has a for-loop. Any solutions on how I can get an event-loop to trigger the for-loop? Thanks.
Upvotes: 1
Views: 245
Reputation: 151
I'm pretty sure it should work if you add await
here
await client.send_file(discord.Object(id='SERVER_ID'), i)
Upvotes: 2