cleaning up some code and adding missed methods to the help file

This commit is contained in:
Luke Robles 2018-06-21 20:50:29 -07:00
parent c941b892cc
commit d6c14b828e
2 changed files with 30 additions and 18 deletions

View File

@ -231,9 +231,13 @@ async def on_message(message):
if message.content.startswith('!help'): if message.content.startswith('!help'):
if len(message.content.split()) > 1: if len(message.content.split()) > 1:
await client.send_message(message.channel, help_methods.parse_message(message.content)) await client.send_message(
message.channel, help_methods.parse_message(message.content)
)
else: else:
await client.send_message(message.channel, embed=help_methods.get_help_embed(client)) await client.send_message(
message.channel, embed=help_methods.get_help_embed(client)
)
if message.content.startswith('!homepage'): if message.content.startswith('!homepage'):
await client.send_message( await client.send_message(

View File

@ -17,6 +17,14 @@ def get_help_message(method):
'Returns the avatar for the mentioned user', 'Returns the avatar for the mentioned user',
'\nUsage: !avatar @somebody' '\nUsage: !avatar @somebody'
], ],
'clap': [
'Returns the shittiest meme created by sassy girls on twitter this century',
'Usage: !clap some text to be meme\'mt'
],
'cleanup': [
'Admin use only. Deletes dragon bot\'s messages from the channel',
'Usage: !cleanup'
],
'decide': [ 'decide': [
'Dragon-bot will help make the tough decisions for you', 'Dragon-bot will help make the tough decisions for you',
' If there is only one option, it will give you a yes or no', ' If there is only one option, it will give you a yes or no',
@ -26,11 +34,10 @@ def get_help_message(method):
'Returns a definiton of a word from urban dictionary', 'Returns a definiton of a word from urban dictionary',
'\nUsage: !define loli' '\nUsage: !define loli'
], ],
'docker': [ 'minecraft': [
'Two supported actions: logs and restart\nlogs: Shows you the', 'Allows you to interact with the minecraft server.',
'last X number of lines from the minecraft server. If no number', 'You can do things like !minecraft logs, or !minecraft map',
' is specified, defaults to 10.\nrestart: will restart the min', ' or !minecraft status to get information about the server'
'ecraft server.'
], ],
'dog': [ 'dog': [
'Returns the URL to a G O O D B O Y E or G I R L', 'Returns the URL to a G O O D B O Y E or G I R L',
@ -53,6 +60,10 @@ def get_help_message(method):
'help': [ 'help': [
'Shows you this message' 'Shows you this message'
], ],
'invite': [
'Generates a one time use invite to the current channel.',
'Be quick! It expires in 12 hours'
],
'lewd': [ 'lewd': [
'Returns a URL for a lewd image.', 'Returns a URL for a lewd image.',
'Can only be used in NSFW channels.', 'Can only be used in NSFW channels.',
@ -102,15 +113,14 @@ def get_help_message(method):
], ],
} }
# Join key : value of the help method they passed in
return "```css\n{} : {}\n```".format(method, ' '.join(supported_methods[method])) return "```css\n{} : {}\n```".format(method, ' '.join(supported_methods[method]))
def get_help_embed(client): def get_help_embed(client):
categories = { categories = {
'fun': ['8ball', 'clap', 'decide', 'dog', 'excuse', 'greentext', 'lewd', 'wallpaper', 'message', 'homepage', 'weather', 'pout', 'smug', 'stock', 'tts'], 'fun': ['clap', 'dog', 'excuse', 'greentext', 'lewd', 'message', 'homepage', 'pout', 'smug'],
'users': ['help', 'purge', 'roles', 'source'], 'util': ['8ball', 'decide', 'wallpaper', 'weather', 'stock', 'tts'],
'docker': ['docker', 'minecraft'], 'users': ['help', 'invite', 'purge', 'roles', 'source', 'minecraft'],
'admin': ['emoji'] 'admin': ['emoji', 'cleanup']
} }
description = "\nBelow you can see all the commands I know.\n\n**Have a nice day!**" description = "\nBelow you can see all the commands I know.\n\n**Have a nice day!**"
@ -118,16 +128,14 @@ def get_help_embed(client):
embed.set_author(name="Hello! I'm {}".format(client.user.name), icon_url=client.user.default_avatar_url) embed.set_author(name="Hello! I'm {}".format(client.user.name), icon_url=client.user.default_avatar_url)
for category in categories: for category in categories:
command_list = []
temp = ''
for command in categories[category]: for command in categories[category]:
temp += '`' + command + '`' + ', ' command_list.append("`{}`".format(command))
temp = temp[:-2] embed.add_field(name=str(category).upper(), value=','.join(command_list))
embed.add_field(name=str(category).upper(), value=temp)
description2 = "**Use `!help <Command>` for more information about a command.** \n\n" + \ description2 = "**Use `!help <Command>` for more information about a command.** \n\n" + \
"**Examples:** \n `!help dog` for detailed help for the dog command \n\n" + \ "**Examples:** \n `!help dog` for detailed help for the dog command \n\n" + \
"**Useful links:** [Support Server](http://discordapp.com), [Twitter](http://twitter.com)" "**Useful links:** [My source code](http://luker.zzzz.io/gitlab/ldooks/dragon-bot), [Server status](http://luker.zzzz.io/status), [Donate](http://luker.zzzz.io/donate)"
embed.add_field(name="\u200b", value=description2, inline=False) embed.add_field(name="\u200b", value=description2, inline=False)
return embed return embed