【发布时间】:2021-03-29 07:50:43
【问题描述】:
我一直在尝试根据我正在观看的教程系列为自己构建一个不和谐机器人。当我尝试运行下面的代码时,出现运行时错误。我在最后一行留下了你需要与机器人连接的令牌,因为我显然不希望任何人能够连接到他。
Traceback (most recent call last):
File "c:\Users\Frederik\Desktop\Python\main.py", line 11, in <module>
client.run("y9QHVpnw5u8aJWYZHMAatZ-nCSrM17YF")
File "C:\Users\Frederik\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 708, in run
return future.result()
File "C:\Users\Frederik\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 687, in runner
await self.start(*args, **kwargs)
File "C:\Users\Frederik\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 650, in start
await self.login(*args, bot=bot)
File "C:\Users\Frederik\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 499, in login
await self.http.static_login(token.strip(), bot=bot)
File "C:\Users\Frederik\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 295, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000249A4C08E50>
Traceback (most recent call last):
File "C:\Users\Frederik\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\Frederik\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\Frederik\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "C:\Users\Frederik\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
PS C:\Users\Frederik\Desktop\Python>
import discord
class MyClient(discord.Client):
async def on_ready(self):
print("Eingeloggt!")
async def on_message(self, message):
print("Nachricht von" + str(message.author) + "enthält" + str(message.content))
client = MyClient()
client.run("")
【问题讨论】:
标签: python python-3.x discord