From 02512e43f3d68ffd89654c5f2e9e3e9a27c0c018 Mon Sep 17 00:00:00 2001 From: Janine vN Date: Sun, 5 Sep 2021 00:31:20 -0400 Subject: Move game and fun commands to Fun folder, fix ddg This moves all the fun commands and games into the fun folder. This commit also makes changes to the duck_game. It was setting a footer during an embed init, which is no longer possible with the version of d.py we use. Additionally, an issue with editing an embed that had a local image loaded. The workaround for the time being is to update the message, not the embed. --- bot/exts/fun/magic_8ball.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 bot/exts/fun/magic_8ball.py (limited to 'bot/exts/fun/magic_8ball.py') diff --git a/bot/exts/fun/magic_8ball.py b/bot/exts/fun/magic_8ball.py new file mode 100644 index 00000000..a7b682ca --- /dev/null +++ b/bot/exts/fun/magic_8ball.py @@ -0,0 +1,30 @@ +import json +import logging +import random +from pathlib import Path + +from discord.ext import commands + +from bot.bot import Bot + +log = logging.getLogger(__name__) + +ANSWERS = json.loads(Path("bot/resources/fun/magic8ball.json").read_text("utf8")) + + +class Magic8ball(commands.Cog): + """A Magic 8ball command to respond to a user's question.""" + + @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(ANSWERS) + await ctx.send(answer) + else: + await ctx.send("Usage: .8ball (minimum length of 3 eg: `will I win?`)") + + +def setup(bot: Bot) -> None: + """Load the Magic8Ball Cog.""" + bot.add_cog(Magic8ball()) -- cgit v1.2.3