Python 永远不等待client.login
我得到了这个错误: 在最后一行执行Python 永远不等待client.login,python,bots,discord.py,Python,Bots,Discord.py,我得到了这个错误: 在最后一行执行client.run(TOKEN)而不是client.login(TOKEN) 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):
client.run(TOKEN)
而不是client.login(TOKEN)
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