簡體   English   中英

永遠不會等待 client.login

[英]client.login is never awaited

import discord

TOKEN = "my token"



class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return

        if message.content == 'cocacola':
            await message.channel.send('cocacola espuma')

client = MyClient()
client.login(TOKEN)

我得到這個錯誤:

 Warning (from warnings module): File "C:/Users/Aorus/AppData/Local/Programs/Python/Python36/discbot.py", line 20 client.login(TOKEN) RuntimeWarning: coroutine 'Client.login' was never awaited

在最后一行執行client.run(TOKEN)而不是client.login(TOKEN)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM