added !plsdog command
This commit is contained in:
parent
67e24d0544
commit
c2884e75cb
2 changed files with 22 additions and 3 deletions
|
@ -23,3 +23,6 @@
|
||||||
|
|
||||||
>**!plsmeme**
|
>**!plsmeme**
|
||||||
> Bot supplies with premium memes from subreddits across Reddit from Huge RedditMemesAPI
|
> Bot supplies with premium memes from subreddits across Reddit from Huge RedditMemesAPI
|
||||||
|
|
||||||
|
>**!plsdog**
|
||||||
|
> Bot supplies with pictures of cute doggos across the whole internet through Dog API
|
22
main.py
22
main.py
|
@ -12,8 +12,10 @@ my_secret = os.environ['TOKEN']
|
||||||
# arrays containing answers
|
# arrays containing answers
|
||||||
xmasAnswers = ['Happy Chrismis!', 'Its Chrismin!', 'Merry Chrisis!', 'Merry Chrysler!']
|
xmasAnswers = ['Happy Chrismis!', 'Its Chrismin!', 'Merry Chrisis!', 'Merry Chrysler!']
|
||||||
coinflip = ['Heads', 'Not Sonic lol (Tails..)']
|
coinflip = ['Heads', 'Not Sonic lol (Tails..)']
|
||||||
|
dogTitles = ['Who let the dogs out?', 'woof', 'Whos a good boy!', 'meow', 'Mr. GoodBoy']
|
||||||
|
|
||||||
|
|
||||||
|
## APIs
|
||||||
# gets a quote from zenquotes.io
|
# gets a quote from zenquotes.io
|
||||||
def get_quote():
|
def get_quote():
|
||||||
response = requests.get('https://zenquotes.io/api/random')
|
response = requests.get('https://zenquotes.io/api/random')
|
||||||
|
@ -23,8 +25,8 @@ def get_quote():
|
||||||
|
|
||||||
# gets a meme from Huge RedditMemesAPI
|
# gets a meme from Huge RedditMemesAPI
|
||||||
def get_meme():
|
def get_meme():
|
||||||
r = requests.get('https://memes.blademaker.tv/api?lang=en')
|
response = requests.get('https://memes.blademaker.tv/api?lang=en')
|
||||||
res = r.json()
|
res = response.json()
|
||||||
title = res['title']
|
title = res['title']
|
||||||
ups = res['ups']
|
ups = res['ups']
|
||||||
downs = res['downs']
|
downs = res['downs']
|
||||||
|
@ -34,12 +36,21 @@ def get_meme():
|
||||||
meme.set_footer(text=f"👍:{ups}")
|
meme.set_footer(text=f"👍:{ups}")
|
||||||
return meme
|
return meme
|
||||||
|
|
||||||
|
# gets a dog from Dog API
|
||||||
|
def get_dog():
|
||||||
|
response = requests.get('https://dog.ceo/api/breeds/image/random')
|
||||||
|
res = response.json()
|
||||||
|
dog = discord.Embed(title = random.choice(dogTitles))
|
||||||
|
dog.set_image(url = res['message'])
|
||||||
|
return dog
|
||||||
|
|
||||||
# when bot is ready
|
# when bot is ready
|
||||||
@client.event # Register an event
|
@client.event # Register an event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print('We have logged in as {0.user}'.format(client))
|
print('We have logged in as {0.user}'.format(client))
|
||||||
|
|
||||||
|
|
||||||
|
## MESSAGE RESPONSES
|
||||||
# bot senses a message & responds
|
# bot senses a message & responds
|
||||||
@client.event
|
@client.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
|
@ -82,6 +93,11 @@ async def on_message(message):
|
||||||
meme = get_meme()
|
meme = get_meme()
|
||||||
await message.channel.send(embed = meme)
|
await message.channel.send(embed = meme)
|
||||||
|
|
||||||
|
# user sends "!plsdog", bot sends picture of dog from Dog API
|
||||||
|
elif message.content.lower().startswith("!plsdog"):
|
||||||
|
dog = get_dog()
|
||||||
|
await message.channel.send(embed = dog)
|
||||||
|
|
||||||
|
|
||||||
# run bot
|
# run bot
|
||||||
client.run(my_secret)
|
client.run(my_secret)
|
Reference in a new issue