当我打开 Pycharm,创建并运行一个不和谐的机器人时,我收到此错误:
Traceback (most recent call last):
File "C:/Users/sghan/PycharmProjects/discordbot/milkbot.py", line 36, in <module>
client.run('NzE2OTk0ODcyNDAxMzMwMjA3.XtYgFA.JOVxgA__TwM9TKnFs905n6zftFM')
File "C:ProgramDataAnaconda3libsite-packagesdiscordclient.py", line 640, in run
return future.result()
File "C:ProgramDataAnaconda3libsite-packagesdiscordclient.py", line 621, in runner
await self.start(*args, **kwargs)
File "C:ProgramDataAnaconda3libsite-packagesdiscordclient.py", line 584, in start
await self.login(*args, bot=bot)
File "C:ProgramDataAnaconda3libsite-packagesdiscordclient.py", line 442, in login
await self.http.static_login(token.strip(), bot=bot)
File "C:ProgramDataAnaconda3libsite-packagesdiscordhttp.py", line 261, in static_login
data = await self.request(Route('GET','/users/@me'))
File "C:ProgramDataAnaconda3libsite-packagesdiscordhttp.py", line 165, in request
async with self.__session.request(method, url, **kwargs) as r:
File "C:ProgramDataAnaconda3libsite-packagesaiohttpclient.py", line 1012, in __aenter__
self._resp = await self._coro
File "C:ProgramDataAnaconda3libsite-packagesaiohttpclient.py", line 483, in _request
timeout=real_timeout
File "C:ProgramDataAnaconda3libsite-packagesaiohttpconnector.py", line 523, in connect
proto = await self._create_connection(req, traces, timeout)
File "C:ProgramDataAnaconda3libsite-packagesaiohttpconnector.py", line 859, in _create_connection
req, traces, timeout)
File "C:ProgramDataAnaconda3libsite-packagesaiohttpconnector.py", line 953, in
_create_direct_connection
sslcontext = self._get_ssl_context(req)
File "C:ProgramDataAnaconda3libsite-packagesaiohttpconnector.py", line 901, in _get_ssl_context
raise RuntimeError('SSL is not supported.')
RuntimeError: SSL is not supported.
源代码是这样的:
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_message(message):
if message.content.startswith('!test'):
await client.send_message(message.channel,'test!!!!')
elif message.content.startswith('!say'):
await client.send_message(message.channel,'leave message')
msg = await client.wait_for_message(timeout=15.0, author=message.author)
if msg is None:
await client.send_message(message.channel,'Please enter within 15 seconds. Retry: !say')
return
else:
await client.send_message(message.channel, msg.content)
client.run('token')
首先,更改您的TOKEN,您刚刚通过发布回溯来揭示它。
此外,您似乎使用的是已弃用的旧版本discord.py
。
尝试将discord.py
模块更新到版本>= 1.3,然后重试。
您应该通过运行以下命令转储当前discord.py
版本:
pip3 uninstall discord.py
单击此处查看如何安装新版本。