diff --git a/dragon-bot.py b/dragon-bot.py index bac6dc40..79a31c4c 100644 --- a/dragon-bot.py +++ b/dragon-bot.py @@ -2,6 +2,7 @@ import random import sys import requests +import help_methods import discord import docker from pybooru import Danbooru @@ -128,25 +129,25 @@ async def on_message(message): await client.send_message(message.channel, "`{}`\n```{}```".format(' '.join(word), definition)) if message.content.startswith('!help'): - supported_methods = { - 'decide': 'Dragon-bot will help make the tough decisions for you\n!decide option 1 or option 2.\n\nIf only one option, it will give you a yes or no', - 'deine': 'Returns a definiton of a word from urban dictionary\n\nUsage: !define loli', - 'docker': 'Two supported actions: logs and restart\n\nlogs: Shows you the last X number of lines from the minecraft server. If no number is specified, defaults to 10.\n\nrestart: will restart the minecraft server if something is fucky', - 'excuse': 'Generates a random excuse you can give your boss', - 'help': 'Prints out a list of everything dragon-bot can do', - 'lewd': 'Returns a URL for a lewd image. Can only be used in NSFW channels', - 'purge': 'Deletes the last 100 messages you sent from the channel you typed purge in', - 'triggered': 'REEEEEEEEEEEEEEEEEE', - 'wallpaper': 'Returns the URL for a 4k wallpaper. You can enter a search term as well, for example, !wallpaper, or, !wallpaper flowers', - } if len(message.content.split()) > 1: method = message.content.split()[1] - if method not in supported_methods.keys(): - await client.send_message(message.channel, "I cant help you with that") + try: + explanation = help_methods.return_help_message(method) + except KeyError: + await client.send_message( + message.channel, + "I can't help you with that" + ) return - await client.send_message(message.channel, "```{}```".format(supported_methods[method])) + await client.send_message( + message.channel, + "```{}```".format(explanation) + ) else: - await client.send_message(message.channel, "I currently have {} methods,\n\n```{}```\n\nYou can get information about a specific method by typing !help ".format(len(supported_methods), ', '.join(supported_methods.keys()))) + await client.send_message( + message.channel, + help_methods.return_help_message('show_all') + ) if 'autis' in message.content or message.content.startswith('!triggered'): diff --git a/help_methods.py b/help_methods.py new file mode 100644 index 00000000..8557cf44 --- /dev/null +++ b/help_methods.py @@ -0,0 +1,47 @@ +def return_help_message(method): + supported_methods = { + 'decide': [ + 'Dragon-bot will help make the tough decisions for you', + '\n\n!decide option 1 or option 2.\n\nIf thre is only', + 'one option, it will give you a yes or no' + ], + 'deine': [ + 'Returns a definiton of a word from urban dictionary', + '\n\nUsage: !define loli' + ], + 'docker': [ + 'Two supported actions: logs and restart\n\nlogs: Shows you the', + 'last X number of lines from the minecraft server. If no number', + 'is specified, defaults to 10.\n\nrestart: will restart the min', + 'ecraft server if something is fucky' + ], + 'excuse': [ + 'Generates a random excuse you can give your boss'], + 'help': [ + 'Prints out a list of everything dragon-bot can do' + ], + 'lewd': [ + 'Returns a URL for a lewd image.', + 'Can only be used in NSFW channels' + ], + 'purge': [ + 'Deletes the last 100 messages you sent from the channel you', + 'typed purge in' + ], + 'triggered': [ + 'REEEEEEEEEEEEEEEEEE'], + 'wallpaper': [ + 'Returns the URL for a 4k wallpaper. You can enter', + 'a search term as well, for example, !wallpaper, or', + ', !wallpaper flowers' + ] + } + + if method == 'show_all': + count = len(supported_methods) + keys = ', '.join(supported_methods.keys()) + + message = "I currently have `{}` methods,\n\n```{}```\n\nYou can get in formation about a specific method by typing !help ".format(count, keys) + else: + message = ' '.join(supported_methods[method]) + return message \ No newline at end of file