autorole.py 文件源码

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

项目:dogbot 作者: slice 项目源码 文件源码
def add(self, ctx: DogbotContext, type: AutoroleType, *roles: discord.Role):
        """Adds autoroles."""
        for role in roles:
            if role.position > ctx.guild.me.top_role.position:
                await ctx.send('I can\'t autorole the role \"{0.name}\". It\'s too high on the role list. Move my '
                               'role above it.'.format(role))
                return

        log.debug('Adding autorole. (type=%s, roles=%s)', type, roles)
        try:
            async with ctx.acquire() as conn:
                await conn.execute('INSERT INTO autoroles (guild_id, type, roles) VALUES ($1, $2, $3)', ctx.guild.id,
                                   type.name, list(map(lambda r: r.id, roles)))
        except asyncpg.UniqueViolationError:
            return await ctx.send('There\'s already autoroles for that type on this server.')
        await ctx.ok()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号