optins.py 文件源码

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

项目:Excalibot 作者: endreman0 项目源码 文件源码
def remove(self, ctx, *roles: discord.Role):
        """Takes the named opt-ins from you."""
        if not roles:
            return await ctx.send('BAKA! You must specify roles!')

        settings = ctx.get(GuildOptins, id=ctx.guild.id).one_or_none()
        if settings is None or not settings.optin_roles:
            return await ctx.send('BAKA! This guild has no optins!')

        optin_ids = {optin.id for optin in settings.optin_roles}
        optin_roles = {role for role in roles if role.id in optin_ids}
        removed = optin_roles & set(ctx.author.roles)
        dont_have = optin_roles - removed
        await ctx.author.remove_roles(*removed)

        responses = []
        if removed:
            responses.append('You have opted out of {}.'.format(format.list(role.name for role in removed)))
        if dont_have:
            responses.append('BAKA! You have not opted into {}!'.format(format.list(role.name for role in dont_have)))
        if len(optin_roles) < len(roles):
            responses.append('BAKA! {}!'.format(format.list((role.name for role in set(roles) - optin_roles), ' is not an optin', ' are not optins')))
        await ctx.send('\n'.join(responses)) # One or more of the above is always true
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号