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)
评论列表
文章目录