Python Discord 机器人 'Event Loop is Closed'

Python Discord Bot 'Event Loop is Closed'

当我 运行 我的 Discord 机器人连接并获得 RuntimeError: Event loop is closed 时。这只是最近发生的,当时我试图修复我的客户端事件不工作,并添加了 intents = discord.Intents().all() 然后将其添加到我的客户端初始化程序 client = commands.Bot(command_prefix = './', intents = intents) 我正在处理的特定事件是自动角色功能。这是我所做的 2 次尝试

@client.event
async def on_member_join(member):
    guild = client.get_guild(528767443653623818)
    channel = client.get_channel(722970243252879420)
    role = guild.get_role(719421779600343110)
    await channel.send(f"Wow, {member} just joined the Pardi!")
    await member.add_roles(role)
    await channel.send(f"{member} is now a {role}")
@client.event
async def on_member_join(member):
    role = get(member.guild.roles, name=ROLE)
    await member.add_roles(role)
    print(f"{member} is now a {role}")

感谢任何帮助:)

EDIT 被要求 post 回溯所以这里是

Traceback (most recent call last):
  File "dbot.py", line 184, in <module>
    client.run(token)
  File "C:\Users\Brandon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 708, in run
    return future.result()
  File "C:\Users\Brandon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 687, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\Brandon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 651, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\Brandon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 586, in connect
    raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go 
to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001CB8B73DF70>
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001CB8B73DF70>
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 116, in __del__
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 108, in close
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 719, in call_soon
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 508, in _check_closed
RuntimeError: Event loop is closed

正如回溯所说,您输入的令牌可能有误或意图未启用

抱歉无法添加评论,因为我的声誉很低

希望它能帮到我,如果不只是再次 ping 我