我试图让用户输入'uploadAll'时能够从文件夹上传所有图像的不和机器人。的代码是:等待具有for循环语法错误的函数
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')
最后一个函数的结果: 类型错误:对象NoneType不能在使用“等待”的表达。我不能等待iter_image,因为它有一个for循环。有关如何获得事件循环以触发for循环的任何解决方案?谢谢。
你不应该发送到服务器ID或discord.Server反对任何更多的它应该工作。当默认频道与服务器共享其ID时,这种方式起作用,但由于“默认频道”的概念被删除,服务器不再保证拥有该频道。 – squaswin