Does anyone know how to get the role ID from the role name? I asked everyone, but he did not give the right answer
Please do not leave a negative rating for no reason, other people may have this problem!
@client.command()
async def createrole(ctx):
guild = ctx.guild
await guild.create_role(name="RGB")
role_id = discord.utils.get(guild.roles,name="RGB")
await ctx.send(role_id)
create_role
returns the role you just created. So
@client.command()
async def createrole(ctx):
guild = ctx.guild
new_role = await guild.create_role(name="RGB")
role_id = new_role.id
await ctx.send(role_id)
The role object docs.