Untitled

 avatar
unknown
python
10 months ago
2.0 kB
2
Indexable
@bot.command(description='Enviar painel para receber cargo') 
async def painelcargo(ctx,amount=1):
  if ctx.author.guild_permissions.ban_members:
    embed = discord.Embed(
    title = 'Reaja para receber o cargo',
    description = 'Reaja a um emoji e receba um cargo especifico.',
    color = 16711680
    )
    try:
        await ctx.channel.purge(limit=amount)
        msg =  await ctx.send(embed = embed)
        await msg.add_reaction('🟢')
        await msg.add_reaction('🔴')

    except Exception as e:
        print(f'Erro ao criar a embed ou adicionar a reação: {e}')
  else:
      mensagem = 'Você não tem permissão para usar o comando!'
      falta = discord.Embed(
            title=f'{mensagem}',
            color= 16711680
      )
      await ctx.send(embed = falta, delete_after=5)



@bot.event
async def on_raw_reaction_add(payload):
    if payload.member.bot:
        return

    guild = bot.get_guild(payload.guild_id)
    if guild is None:
        print("Servidor não encontrado!")
        return

    role1 = discord.utils.get(guild.roles, name='Gamer')
    role2 = discord.utils.get(guild.roles, name='Mini-Games')

    if role1 is None:
        print("Cargo não encontrado!")
        return

    if payload.emoji.name == '🟢':
        member = guild.get_member(payload.user_id)
        if member is not None:
            try:
                await member.add_roles(role1)
                print(f"Cargo 'Gamer' adicionado a {member.name}")
            except Exception as e:
                print(f"Erro ao adicionar o cargo: {e}")


    if payload.emoji.name == '🔴':
        member = guild.get_member(payload.user_id)
        if member is not None:
            try:
                await member.add_roles(role2)
                print(f"Cargo 'Mini-Games' adicionado a {member.name}")
            except Exception as e:
                print(f"Erro ao adicionar o cargo: {e}")
Editor is loading...
Leave a Comment