adding a help message if someone uses meme incorrectly
This commit is contained in:
parent
f0665d5318
commit
a88ca8a2b7
@ -127,8 +127,6 @@ async def on_message(message):
|
||||
embed_description="[Direct Link]({})".format(user.avatar_url.replace('.webp', '.png'))
|
||||
)
|
||||
)
|
||||
if message.content.startswith('!meme'):
|
||||
await client.send_message(message.channel, meme_gen.parse_message(message.content))
|
||||
|
||||
if message.content.startswith('!birb'):
|
||||
await client.send_message(
|
||||
@ -239,6 +237,11 @@ async def on_message(message):
|
||||
'You can only use this command in NSFW channels'
|
||||
)
|
||||
|
||||
if message.content.startswith('!meme'):
|
||||
await client.delete_message(message)
|
||||
await client.send_message(message.channel, meme_gen.parse_message(message.content))
|
||||
|
||||
|
||||
if message.content.startswith('!weather'):
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
|
@ -96,7 +96,7 @@ def get_help_message(method):
|
||||
],
|
||||
'meme': [
|
||||
'Generates a meme on the fly!',
|
||||
'\nUsage: !meme doge top text; bottom text'
|
||||
'\n\nUsage: !meme doge top text; bottom text'
|
||||
],
|
||||
'homepage': [
|
||||
'This function now outputs the SWEET-ASS picture of the day.',
|
||||
|
@ -1,10 +1,13 @@
|
||||
import os, requests
|
||||
import os
|
||||
import requests
|
||||
|
||||
import help_methods
|
||||
|
||||
supported_templates = sorted(list(map(lambda x: x.split('/')[-1], requests.get('https://memegen.link/api/templates/').json().values())))
|
||||
|
||||
def parse_message(message):
|
||||
if len(message.split()) < 2:
|
||||
return get_templates()
|
||||
if len(message.split()) <= 2:
|
||||
return get_meme_help()
|
||||
|
||||
escaped_chars = {'_' : '__', ' ' : '_', '-' : '--', '?' : '~q', '%' : '~p', '#' : '~h', '/' : '~s', '\'\'' : '\"'}
|
||||
|
||||
@ -39,6 +42,8 @@ def get_meme_url(template, upper, lower, usesTemplate):
|
||||
meme = '{}/{}/{}/{}.{}'.format(base_URL, template, upper, lower, default_format)
|
||||
return meme
|
||||
|
||||
def get_templates():
|
||||
return "You must supply a valid template for the meme. Templates are one of the following: \n```" + ', '.join(supported_templates) + '```'
|
||||
|
||||
def get_meme_help():
|
||||
return "{}\nYou must supply a valid template for the meme. Templates are one of the following: \n```{}```".format(
|
||||
help_methods.get_help_message('meme'),
|
||||
', '.join(supported_templates)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user