我試圖讓用戶輸入'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