当我运行我的 Discord 机器人时,它会连接并获得 RuntimeError: Event loop is closed
。这只发生在最近我试图修复我的客户端事件不起作用时,并添加了 intents = discord.Intents().all()
,然后将其添加到我的客户端初始值设定项 client = commands.Bot(command_prefix = './', intents = intents)
我正在处理的特定事件是自动角色功能。这是我尝试的 2 次p>
@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}")
感谢任何帮助:)
编辑被要求发布回溯,所以在这里
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
答案 0 :(得分:1)
正如回溯所说,您输入的令牌可能有误或未启用意图
抱歉无法添加评论,因为我的声誉很低
如果不只是再次联系我,希望它会有所帮助