command_personal.py 文件源码

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

项目:snake 作者: AnonymousDapper 项目源码 文件源码
def blacklist_search(self, ctx, *, obj:MultiMention):
        if isinstance(obj, discord.Server):
            kwargs = dict(server_id=int(obj.id))

        elif isinstance(obj, discord.Channel):
            kwargs = dict(channel_id=int(obj.id))

        elif isinstance(obj, discord.Role):
            kwargs = dict(role_id=int(obj.id))

        elif isinstance(obj, discord.Member):
            kwargs = dict(user_id=int(obj.id))

        with self.bot.db_scope() as session:
            blacklist_objs = session.query(sql.Blacklist).filter_by(**kwargs).all()

            if len(blacklist_objs) > 0:
                result_text = f"```md\n# {obj.__class__.__name__} {str(obj)} is blacklisted for\n" + "\n".join(f"- {b_obj.data}" for b_obj in blacklist_objs) + "\n```"
            else:
                result_text = f"```md\n# {obj.__class__.__name__} {str(obj)} is not blacklisted\n```"

        await self.bot.say(result_text)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号