自定义角色命令



我需要有关custom_role命令的帮助。它应该为用户角色创建自定义名称和颜色。

现在我只有:

@Bot.command()
async def custom_role(ctx):
await ctx.guild.create_role(name = "role")
emb = discord.Embed(description = "Role created!", color = 0x2ecc71)
await ctx.send(embed = emb)

您几乎完成了,您可以将角色名称和颜色作为参数传递,并使用指定的参数创建自定义角色:

@Bot.command()
async def custom_role(ctx, colour: str, *, name: str):
colour = discord.Color(value=int(colour, 16))
await ctx.guild.create_role(name = name, colour=colour)
emb = discord.Embed(description = "Role created!", color = 0x2ecc71)
await ctx.send(embed = emb)

用法示例(假设前缀为"!"(:

!custom_role 0xa83232 test role # Creates a role named 'test role' in the color red

也许这会有所帮助:

@Bot.command()
async def custom_role(ctx):
permissions = discord.Permissions()
await ctx.guild.create_role(name = 'role', colour = discord.Colour(0x2ecc71), permissions = permissions)

在此处了解有关权限的详细信息。

最新更新