Я написал бот дискорд который выдает роли по эмодзи, но при запуске пишет ошибку вот код:
import discord
import config
intents = discord.Intents.default()
intents.members = True
class DiscordBot(discord.Client):
async def on_ready(self):
print(f"Бот {self.user} в сети")
async def on_raw_reaction_add(self, paylood):
if paylood.message.id == config.ID_POST:
channel = self.get_channel(paylood.channel_id)
message = await channel.fetch_message(paylood.message_id)
user = discord.utils.get(message.guild.members, id=paylood.user_id)
emoji = str(paylood.emoji)
try:
role = discord.utils.get(message.guild.roles, id=config.ROLE_LIST(emoji))
if len([i for i in user.roles if i.id not in config.USER_ROLES_LIST]) <= config.MAX_ROLES:
await user.add_roles(role)
print(f"{user.name} получил роль {role.name}")
else:
await message.remove_reaction(paylood.emoji, user)
print(f"Ошибка! пользователь {user.name} пытался получить слишком много ролей")
except Exception as _ex:
print(repr(_ex))
async def on_raw_reaction_remove(self, paylood):
channel = self.get_channel(paylood.channel_id)
message = await channel.fetch_message(paylood.message_id)
user = discord.utils.get(message.guild.members, id=paylood.user_id)
try:
emoji = str(paylood.emoji)
role = discord.utild.get(message.guild.roles, id=config.ROLE_LIST[emoji])
await user.remove_roles(role)
except Exception as _ex:
print(repr(_ex))
client = DiscordBot(intents=intents)
client.run(config.BOT_TOKEN)
вот config.py
BOT_TOKEN = "тОКЕН"
ID_POST = 0
USER_ROLES_LIST = ()
MAX_ROLES = 3
ROLE_LIST = {
"✅": 1051595649646338118, #Верифицированый
}
вот ошибка
Traceback (most recent call last):
File "C:\Users\hadji\PycharmProjects\pythonProject\dsrolebot\rolebot.py", line 46, in <module>
client.run(config.BOT_TOKEN)
File "C:\Users\hadji\PycharmProjects\pythonProject\venv\lib\site-packages\discord\client.py", line 828, in run
asyncio.run(runner())
File "C:\Users\hadji\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\hadji\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\Users\hadji\PycharmProjects\pythonProject\venv\lib\site-packages\discord\client.py", line 817, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\hadji\PycharmProjects\pythonProject\venv\lib\site-packages\discord\client.py", line 746, in start
await self.connect(reconnect=reconnect)
File "C:\Users\hadji\PycharmProjects\pythonProject\venv\lib\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.