From 56acadbc6215bfd393a4d0caa015df3319ca563e Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Sun, 18 Dec 2022 20:21:18 -0500 Subject: [PATCH] Customize number of memes in memedump --- src/memes.py | 10 +++++++++- src/on_message.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/memes.py b/src/memes.py index 5a4fb2e..c58263b 100644 --- a/src/memes.py +++ b/src/memes.py @@ -271,7 +271,15 @@ async def memeCount(command, message, client): # get a set of random memes async def memeDump(command, message, client): await message.channel.send("Getting your memes...") - for i in range(0,5): + count = 5 + if len(command) > 1: + try: + count = int(command[1]) + except: + print("Tried to parse a number, got (" + command[1] + ")") + count = 5 + + for i in range(0,count): meme = getRandomMeme() ready_meme = getDiscordReadyObjectFromS3(meme) if isinstance(ready_meme, str): diff --git a/src/on_message.py b/src/on_message.py index debcfae..3ef4a92 100644 --- a/src/on_message.py +++ b/src/on_message.py @@ -10,8 +10,8 @@ async def showHelp(very, useless, arguments): str += " Get a meme. Query for the exact name or search. Paramater is optional\n" str += "!memecount\n" str += " Print total number of memes in the store\n" - str += "!memedump\n" - str += " Get 5 random memes\n" + str += "!memedump [COUNT]\n" + str += " Get COUNT random memes. If COUNT is not provided, we default to 5\n" str += "!allmemes QUERY\n" str += " Get all memes that are like the given query\n" str += "!help\n"