added new command !plsmeme

This commit is contained in:
Sid 2021-12-18 22:30:11 +01:00 committed by GitHub
parent b8bbefb120
commit 0f65cac351
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -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
> Bot inspires user with a quote from zenquotes.io
>**!plsmeme**
> Bot supplies with premium memes from subreddits across Reddi from Huge RedditMemesAPI

17
main.py
View file

@ -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)