@slemsik

Ошибка при запуске бота для discord на python, как решить?

Делал как сказано в доках, а вылезает ошибка
Код:
import discord
from discord.ext import commands

intents = discord.Intents.all()

intents.message_content = True
bot = commands.Bot(command_prefix='>', intents=intents)

@bot.command()
async def ping(ctx):
    await ctx.send('pong')

bot.run('MTAxMjk3NDc4MTMyMDE1NTE2Ng.Gwg3UX.b_cYKRNCsrOljm1Q_bCe10bS3cZzqR-fEQkrzU')


Ошибка:
Traceback (most recent call last):
  File "C:\Users\slemsik\Documents\ds_py\discord.py\main.py", line 12, in <module>
    bot.run('MTAxMjk3NDc4MTMyMDE1NTE2Ng.Gwg3UX.b_cYKRNCsrOljm1Q_bCe10bS3cZzqR-fEQkrzU')
  File "C:\Users\slemsik\Documents\ds_py\discord.py\discord\client.py", line 828, in run
    asyncio.run(runner())
  File "C:\Users\slemsik\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\slemsik\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Users\slemsik\Documents\ds_py\discord.py\discord\client.py", line 817, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\slemsik\Documents\ds_py\discord.py\discord\client.py", line 746, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\slemsik\Documents\ds_py\discord.py\discord\client.py", line 672, 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 0x00000235A8C71F30>
Traceback (most recent call last):
  File "C:\Users\slemsik\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\slemsik\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\slemsik\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
    self._check_closed()
  File "C:\Users\slemsik\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000235A8C71F30>
Traceback (most recent call last):
  File "C:\Users\slemsik\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
  File "C:\Users\slemsik\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
  File "C:\Users\slemsik\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
  File "C:\Users\slemsik\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
RuntimeError: Event loop is closed
  • Вопрос задан
  • 2468 просмотров
Решения вопроса 1
@PavelMos
Т.к. это в виндах, то рекомендуют попробовать
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

https://stackoverflow.com/questions/45600579/async...
Ответ написан
Пригласить эксперта
Ответы на вопрос 2
В тексте ошибки всё написано:
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.


"Осколок" с ID None запрашивает привилегированные намерения (intents), которые не были включены на портале разработчика. Рекомендуется пройти на https://discord.com/developers/applications/ и включить привилегированные намерения на странице вашего приложения. Если это невозможно, вместо этого подумайте над отключением привилегированных намерений.
Ответ написан
Комментировать
@White_Worker
Сегодня столкнулся с похожей проблемой:
Bot connection
[2022-09-19 09:54:20] [INFO    ] discord.client: logging in using static token
Traceback (most recent call last):
  File "C:\Users\litov\OneDrive\Рабочий стол\python_work\Новая папка\bot.py", line 90, in <module>
    client.run(settings ['TOKEN'])
  File "C:\Users\litov\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 828, in run
    asyncio.run(runner())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2032.0_x64__qbz5n2kfra8p0\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2032.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Users\litov\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 817, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\litov\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 746, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\litov\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 672, 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.

Бот имеет права администратора, которые были включены непосредственно на портале разработчика. Что делать?
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы