From f8a179df350eb3abb7f3595aaff3dbca312f540c Mon Sep 17 00:00:00 2001 From: ToxicKidz Date: Sat, 15 May 2021 13:31:34 -0400 Subject: chore: Make things that are only used once constants --- bot/exts/evergreen/magic_8ball.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'bot/exts/evergreen/magic_8ball.py') diff --git a/bot/exts/evergreen/magic_8ball.py b/bot/exts/evergreen/magic_8ball.py index 4b3ed2a4..28ddcea0 100644 --- a/bot/exts/evergreen/magic_8ball.py +++ b/bot/exts/evergreen/magic_8ball.py @@ -9,18 +9,17 @@ from bot.bot import Bot log = logging.getLogger(__name__) +ANSWERS = json.loads(Path("bot/resources/evergreen/magic8ball.json").read_text("utf8")) + class Magic8ball(commands.Cog): """A Magic 8ball command to respond to a user's question.""" - def __init__(self): - self.answers = json.loads(Path("bot/resources/evergreen/magic8ball.json").read_text("utf8")) - @commands.command(name="8ball") async def output_answer(self, ctx: commands.Context, *, question: str) -> None: """Return a Magic 8ball answer from answers list.""" if len(question.split()) >= 3: - answer = random.choice(self.answers) + answer = random.choice(ANSWERS) await ctx.send(answer) else: await ctx.send("Usage: .8ball (minimum length of 3 eg: `will I win?`)") -- cgit v1.2.3