roles.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:GAFBot 作者: DiNitride 项目源码 文件源码
def add(self, ctx, *, role: CustomRoleConverter):
        """
        Adds a role to the list that can be assigned
        """
        if not isinstance(role, discord.Role):
            await ctx.send("Could not find role! Creating blank role now :crayon: ")
            role = await ctx.guild.create_role(name=role,
                                               colour=Colour.orange(),
                                               mentionable=True,
                                               reason="Role automagically created by GAF Bot for the role list")
        if role.position >= ctx.author.top_role.position:
            await ctx.send("Unable to add role due to Hierarchy")
        else:
            guild_config = await self.bot.get_guild_config(ctx.guild.id)
            guild_config["roles"][role.id] = role.name
            await self.bot.set_guild_config(ctx.guild.id, guild_config)
            await ctx.send("Added {} to the role list".format(role.name))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号