@bot.slash_command(name="t")
async def choose_roles(ctx):
if ctx.author.id != 1099953599141904507:
await ctx.send("Эта команда доступна только для определенного пользователя", ephemeral=True)
return
await ctx.send("Успешно", ephemeral=True)
channel = bot.get_channel(1206213122713722911)
message = await channel.send(
"Выберите свои роли:\n"
"Демократия ❮:ballot_box:❯\n"
"Либериализм ❮:fist_tone2:❯\n"
"Фашизм ❮:knife:❯\n"
"Нацизм ❮:man_tone1:❯\n"
"Неонацизм ❮:police_officer_tone2:❯\n"
"Консерватизм ❮:maple_leaf:❯\n"
"Социал-Демократия ❮:statue_of_liberty:❯\n"
"Коммунизм ❮:game_die:❯\n"
"Социализм ❮:eagle:❯\n"
"Капитализм ❮:tophat:❯\n"
"Анархизм ❮:spider:❯\n"
"Пацифизм ❮:wilted_rose:❯\n"
"Монархия ❮:crown:❯\n"
"Империализм ❮:swan:❯"
)
reactions = [":ballot_box:", ":fist_tone2:", ":knife:", ":man_tone1:", ":police_officer_tone2:", ":maple_leaf:", ":statue_of_liberty:", ":game_die:", ":eagle:", ":tophat:", ":spider:", ":wilted_rose:", ":crown:", ":swan:"]
roles = [
"Демократия", "Либериализм", "Фашизм", "Нацизм", "Неонацизм",
"Консерватизм", "Коммунизм", "Социализм", "Капитализм",
"Анархизм", "Пацифизм", "Монархия", "Империализм"
]
for reaction in reactions:
await message.add_reaction(reaction)
def check(reaction, user):
return user == ctx.author and reaction.message.id == message.id and str(reaction.emoji) in reactions
while True:
reaction, _ = await bot.wait_for("reaction_add", check=check)
role_index = reactions.index(str(reaction.emoji))
role_name = roles[role_index]
role = disnake.utils.get(ctx.guild.roles, name=role_name)
if role:
await ctx.author.add_roles(role)
for emoji in reactions:
if emoji != str(reaction.emoji):
await message.remove_reaction(emoji, ctx.author)
@bot.event
async def on_raw_reaction_add(payload):
channel = bot.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
if message.author == bot.user:
return
member = message.guild.get_member(payload.user_id)
if member.bot:
return
emoji = payload.emoji.name
if emoji in reactions:
role_index = reactions.index(emoji)
role_name = roles[role_index]
role = disnake.utils.get(message.guild.roles, name=role_name)
if role:
await member.add_roles(role)
Как решить баг? Когда я нажимаю на реакцию нечего не происходит.
Это disnake. Ошибки в консоли нету. Как это починить?