Answer the question
In order to leave comments, you need to log in
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)
Answer the question
In order to leave comments, you need to log in
@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 questionAsk a Question
731 491 924 answers to any question