Add quote list subcommand

This commit is contained in:
2021-01-29 11:34:21 +01:00
parent 3daa251e59
commit 9abfd558f1

19
bot.py
View File

@@ -261,6 +261,25 @@ async def quote_command(ctx: commands.Context, author: Optional[str], *, quote:
await ctx.channel.send(quote + '\n *~' + author + '*')
else:
await ctx.channel.send("No quotes present!")
elif author == 'list':
def create_list_embed(quote_author: str, _quotes: List[str]) -> discord.Embed:
embed: discord.Embed = discord.Embed(
title=quote_author,
description='\n'.join(_quotes)
)
return embed
if quote is None:
coroutines = []
for author, author_quotes in quotes.items():
coroutines.append(ctx.send(embed=create_list_embed(author, author_quotes)))
await asyncio.gather(*coroutines)
else:
author = quote.strip().title()
if author in quotes:
await ctx.send(embed=create_list_embed(author, quotes[author]))
else:
await ctx.send("No such author!")
else:
author = author.strip().title()
if quote: