TLDR:我尝试在我的 Mac 上使用 Discord.py 一段时间了,但我尝试过的所有方法都不起作用。所有其他解决方案都不起作用!
请帮忙。几个月来我一直在尝试让 Discord.py 工作,但我无法让它工作。这是我的代码[显然,我将重置我的令牌]:
import discord
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 == 'ping':
await message.channel.send('pong')
client = MyClient()
client.run("NzQxNzUzMTQ0MDA2MTQ4MTU2.Xy8Jcg.wBNInfNrj--ZtinuzQ-b4I7H1jo")
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
Traceback (most recent call last):
File "/Users/meow/programming/PycharmProjects/BulmeniBot/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1050, in create_connection
transport, protocol = await self._create_connection_transport(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1080, in …Run Code Online (Sandbox Code Playgroud)