def _get_random_author_quote(self, ctx, author):
sid = ctx.message.server.id
if sid not in self.quotes or len(self.quotes[sid]) == 0:
raise AssertionError("There are no quotes in this server!")
if isinstance(author, discord.User):
uid = author.id
quotes = [(i, q) for i, q in enumerate(self.quotes[sid]) if q['author_id'] == uid]
else:
quotes = [(i, q) for i, q in enumerate(self.quotes[sid]) if q['author_name'] == author]
if len(quotes) == 0:
raise commands.BadArgument("There are no quotes by %s." % author)
return randchoice(quotes)
评论列表
文章目录