W
W
WorldDev2021-11-01 19:01:38
Python
WorldDev, 2021-11-01 19:01:38

How to make a command for issuing roles?

Help. I want to make a command to issue roles on discord.py. Here's how it should be done: ?grant @mention user @mention role. For example ?grant @Fox#1632 @ Moderator. Can you give me a code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavlosik, 2021-11-03
@Pavlosik

@client.command()
async def news(ctx, member: discord.Member = None):
    if member is None:
    role = ctx.guild.get_role(
        ID роли которую хочешь выдать
    )  
    await ctx.author.add_roles(role)
    await ctx.send(
        embed=discord.Embed(
            description=f"**Вы взяли себе роль {role.mention}**",
            color=discord.Color.purple(),
        )
    )
   else:
role = ctx.guild.get_role(
        ID роли которую хочешь выдать
    )  
    await ctx.author.add_roles(role)
    await ctx.send(
        embed=discord.Embed(
            description=f"Вы выдали **{ctx.author}** роль {role.mention}",
            color=discord.Color.purple(),
        )
    )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question