D
D
Den_Rou_OFFICIAL2021-10-25 02:27:37
Bots
Den_Rou_OFFICIAL, 2021-10-25 02:27:37

How to make a bot to give out personal roles?

I'm trying to create a bot that will issue personal roles on command, for example: you write a $lr test and it gives it to you
This part I did, but I can't figure out how to make it issue a role with a custom color, for example: $lr test (here is the color code ).

@client.command()
async def lr(ctx, *, nam):
    try:
        await ctx.guild.create_role(name=nam, colour=discord.Colour(), permissions=discord.Permissions(permissions=2251673089))
        role = discord.utils.get(ctx.guild.roles, name=nam)
        await ctx.message.author.add_roles(role)

What would be in colour=discord.Colour() to insert the color written in the command.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RealSosiso4ka, 2021-10-29
@Den_Rou_OFFICIAL

@client.command()
async def lr(ctx, nam, col): #добавляем параметр col в команду (это и будет цвет роли)
    col = int(col) #изменяем формат параметра, введённого пользователем, на int
    await ctx.guild.create_role(name=nam, colour=discord.Colour(col),  #цвет заменяем на col
                                 permissions=discord.Permissions(permissions=2251673089)) 
    role = discord.utils.get(ctx.guild.roles, name=nam)
    await ctx.message.author.add_roles(role)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question