diff options
| author | 2019-03-22 13:58:29 -0400 | |
|---|---|---|
| committer | 2019-03-22 13:58:29 -0400 | |
| commit | 626ea38f75c26de7ebc8ab984e0fddd0fe827b01 (patch) | |
| tree | e15d5bd86c605ec16758cd546a60dc41d0750f37 /bot/seasons/evergreen/magic_8ball.py | |
| parent | Move list to evergreen resource directory (diff) | |
Change path to evergreen directory
Diffstat (limited to 'bot/seasons/evergreen/magic_8ball.py')
| -rw-r--r-- | bot/seasons/evergreen/magic_8ball.py | 35 | 
1 files changed, 7 insertions, 28 deletions
diff --git a/bot/seasons/evergreen/magic_8ball.py b/bot/seasons/evergreen/magic_8ball.py index 3fb57ed8..c13d2637 100644 --- a/bot/seasons/evergreen/magic_8ball.py +++ b/bot/seasons/evergreen/magic_8ball.py @@ -1,55 +1,34 @@ +import json  import logging  import random  from discord.ext import commands +from pathlib import Path  log = logging.getLogger(__name__) -answers = [ -    "It is certain", -    "It is decidedly so", -    "Without a doubt", -    "Yes definitely", -    "You may rely on it", -    "As I see it, yes", -    "Most likely", -    "Outlook good", -    "Yes", -    "Signs point to yes", -    "Reply hazy try again", -    "Ask again later", -    "Better not tell you now", -    "Cannot predict now", -    "Concentrate and ask again", -    "Don't count on it", -    "My reply is no", -    "My sources say no", -    "Outlook not so good", -    "Very doubtful", -] - - -class Magic_8ball: +class Magic8ball:      """      A Magic 8ball command to respond to a users question.      """      def __init__(self, bot):          self.bot = bot +        with open(Path("bot", "resources", "evergreen", "magic8ball.json"), "r") as file: +            self.answers = json.load(file)      @commands.command(name="8ball")      async def output_answer(self, ctx, question: list):          """          Return a magic 8 ball answer from answers list.          """ -          if len(question) >= 3: -            answer = random.choice(answers) +            answer = random.choice(self.answers)              await ctx.send(answer)  # Required in order to load the cog, use the class name in the add_cog function.  def setup(bot): -    bot.add_cog(Magic_8ball(bot)) +    bot.add_cog(Magic8ball(bot))      log.debug("Magic 8ball cog loaded")  |