diff --git a/app/dragon-bot.py b/app/dragon-bot.py index 1b56c091..d8e5f756 100644 --- a/app/dragon-bot.py +++ b/app/dragon-bot.py @@ -230,11 +230,10 @@ async def on_message(message): ) if message.content.startswith('!help'): - await client.send_message(message.channel, "Sorry {}, But the help command is currently broken. \nIf you'd like to help fix it, take a look at the open issue\nhttp://luker.zzzz.io/gitlab/ldooks/dragon-bot/issues/2".format(message.author.mention)) - # await client.send_message( - # message.author, - # help_methods.parse_message(message.content) - # ) + if len(message.content.split()) > 1: + await client.send_message(message.channel, help_methods.parse_message(message.content)) + else: + await client.send_message(message.channel, embed=help_methods.get_help_embed(client)) if message.content.startswith('!homepage'): await client.send_message( diff --git a/app/help_methods.py b/app/help_methods.py index 714a49b8..bd0d463c 100644 --- a/app/help_methods.py +++ b/app/help_methods.py @@ -1,3 +1,4 @@ +import discord def get_help_message(method): """ get_help_message(method) @@ -101,26 +102,40 @@ def get_help_message(method): ], } - # Print out every help method - if method == 'show_all': - # Might be a better way to do this, but build a list of method : description - build_message = [] - for key, value in supported_methods.items(): - build_message.append("\n{} : {}\n".format(key, ' '.join(supported_methods[key]))) - # Join every element of the list with a space - message = ' '.join(build_message) - else: - # Join key : value of the help method they passed in - message = "{} : {}".format(method, ' '.join(supported_methods[method])) + # Join key : value of the help method they passed in + return "```css\n{} : {}\n```".format(method, ' '.join(supported_methods[method])) - return "\n{}\n".format(message) +def get_help_embed(client): + categories = { + 'fun': ['8ball', 'clap', 'decide', 'dog', 'excuse', 'greentext', 'lewd', 'wallpaper', 'message', 'homepage', 'weather', 'pout', 'smug', 'stock', 'tts'], + 'users': ['help', 'purge', 'roles', 'source'], + 'docker': ['docker', 'minecraft'], + 'admin': ['emoji'] + } + + description = "\nBelow you can see all the commands I know.\n\n**Have a nice day!**" + embed = discord.Embed(description=description, color=0x428bca, type="rich") + embed.set_author(name="Hello! I'm {}".format(client.user.name), icon_url=client.user.default_avatar_url) + + for category in categories: + + temp = '' + for command in categories[category]: + temp += '`' + command + '`' + ', ' + temp = temp[:-2] + embed.add_field(name=str(category).upper(), value=temp) + + description2 = "**Use `!help ` for more information about a 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)" + + embed.add_field(name="\u200b", value=description2, inline=False) + return embed def parse_message(message): - method = 'show_all' - if len(message.split()) > 1: - method = message.split()[1] + method = message.split()[1] try: explanation = get_help_message(method) except KeyError: - return "I can't help you with that" - return "```css\n{}\n```".format(explanation) + return "This command could not be found." + return explanation