From 0f65cac3515781fbb00dc1372f1c4119ff273526 Mon Sep 17 00:00:00 2001 From: Sid <93219711+SindreKjelsrud@users.noreply.github.com> Date: Sat, 18 Dec 2021 22:30:11 +0100 Subject: [PATCH] added new command !plsmeme --- commands.md | 5 ++++- main.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/commands.md b/commands.md index 4cb359e..71535bb 100644 --- a/commands.md +++ b/commands.md @@ -19,4 +19,7 @@ > Someone writes "merry christmas" and bot responds w/ legendary vine quote selected from an array >**!inspire** -> Bot inspires user with a quote from zenquotes.io \ No newline at end of file +> Bot inspires user with a quote from zenquotes.io + +>**!plsmeme** +> Bot supplies with premium memes from subreddits across Reddi from Huge RedditMemesAPI \ No newline at end of file diff --git a/main.py b/main.py index 35c9b55..4fa8f0e 100644 --- a/main.py +++ b/main.py @@ -21,6 +21,18 @@ def get_quote(): quote = json_data[0]['q'] + ' -' + json_data[0]['a'] return(quote) +# gets a meme from Huge RedditMemesAPI +def get_meme(): + r = requests.get('https://memes.blademaker.tv/api?lang=en') + res = r.json() + title = res['title'] + ups = res['ups'] + downs = res['downs'] + sub = res['subreddit'] + meme = discord.Embed(title = f'{title}\nSubreddit: {sub}') + meme.set_image(url = res['image']) + meme.set_footer(text=f"👍:{ups}") + return m # when bot is ready @client.event # Register an event @@ -65,6 +77,11 @@ async def on_message(message): quote = get_quote() await message.channel.send(quote) + # user sends "!plsmeme", bot sends meme from random subreddit + elif message.content.lower().startswith("!plsmeme"): + meme = get_meme() + await message.channel.send(embed = meme) + # run bot client.run(my_secret) \ No newline at end of file