diff options
author | 2021-09-05 00:31:20 -0400 | |
---|---|---|
committer | 2021-09-05 00:31:20 -0400 | |
commit | 02512e43f3d68ffd89654c5f2e9e3e9a27c0c018 (patch) | |
tree | 4b62a6dbb39601f02aa435c7eb8a10433585c3bb | |
parent | Move snakes commands into fun folder (diff) |
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.
-rw-r--r-- | bot/exts/fun/__init__.py (renamed from bot/exts/evergreen/__init__.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/battleship.py (renamed from bot/exts/evergreen/battleship.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/catify.py (renamed from bot/exts/evergreen/catify.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/coinflip.py (renamed from bot/exts/evergreen/coinflip.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/connect_four.py (renamed from bot/exts/evergreen/connect_four.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/duck_game.py (renamed from bot/exts/evergreen/duck_game.py) | 40 | ||||
-rw-r--r-- | bot/exts/fun/fun.py (renamed from bot/exts/evergreen/fun.py) | 2 | ||||
-rw-r--r-- | bot/exts/fun/game.py (renamed from bot/exts/evergreen/game.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/magic_8ball.py (renamed from bot/exts/evergreen/magic_8ball.py) | 2 | ||||
-rw-r--r-- | bot/exts/fun/minesweeper.py (renamed from bot/exts/evergreen/minesweeper.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/movie.py (renamed from bot/exts/evergreen/movie.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/recommend_game.py (renamed from bot/exts/evergreen/recommend_game.py) | 2 | ||||
-rw-r--r-- | bot/exts/fun/rps.py (renamed from bot/exts/evergreen/rps.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/space.py (renamed from bot/exts/evergreen/space.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/speedrun.py (renamed from bot/exts/evergreen/speedrun.py) | 2 | ||||
-rw-r--r-- | bot/exts/fun/status_codes.py (renamed from bot/exts/evergreen/status_codes.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/tic_tac_toe.py (renamed from bot/exts/evergreen/tic_tac_toe.py) | 0 | ||||
-rw-r--r-- | bot/exts/fun/trivia_quiz.py (renamed from bot/exts/evergreen/trivia_quiz.py) | 2 | ||||
-rw-r--r-- | bot/exts/fun/wonder_twins.py (renamed from bot/exts/evergreen/wonder_twins.py) | 2 | ||||
-rw-r--r-- | bot/exts/fun/xkcd.py (renamed from bot/exts/evergreen/xkcd.py) | 0 | ||||
-rw-r--r-- | bot/resources/fun/LuckiestGuy-Regular.ttf (renamed from bot/resources/evergreen/LuckiestGuy-Regular.ttf) | bin | 58292 -> 58292 bytes | |||
-rw-r--r-- | bot/resources/fun/all_cards.png (renamed from bot/resources/evergreen/all_cards.png) | bin | 155466 -> 155466 bytes | |||
-rw-r--r-- | bot/resources/fun/caesar_info.json (renamed from bot/resources/evergreen/caesar_info.json) | 0 | ||||
-rw-r--r-- | bot/resources/fun/ducks_help_ex.png (renamed from bot/resources/evergreen/ducks_help_ex.png) | bin | 343921 -> 343921 bytes | |||
-rw-r--r-- | bot/resources/fun/game_recs/chrono_trigger.json (renamed from bot/resources/evergreen/game_recs/chrono_trigger.json) | 0 | ||||
-rw-r--r-- | bot/resources/fun/game_recs/digimon_world.json (renamed from bot/resources/evergreen/game_recs/digimon_world.json) | 0 | ||||
-rw-r--r-- | bot/resources/fun/game_recs/doom_2.json (renamed from bot/resources/evergreen/game_recs/doom_2.json) | 0 | ||||
-rw-r--r-- | bot/resources/fun/game_recs/skyrim.json (renamed from bot/resources/evergreen/game_recs/skyrim.json) | 0 | ||||
-rw-r--r-- | bot/resources/fun/html_colours.json (renamed from bot/resources/evergreen/html_colours.json) | 0 | ||||
-rw-r--r-- | bot/resources/fun/magic8ball.json (renamed from bot/resources/evergreen/magic8ball.json) | 0 | ||||
-rw-r--r-- | bot/resources/fun/speedrun_links.json (renamed from bot/resources/evergreen/speedrun_links.json) | 0 | ||||
-rw-r--r-- | bot/resources/fun/trivia_quiz.json (renamed from bot/resources/evergreen/trivia_quiz.json) | 0 | ||||
-rw-r--r-- | bot/resources/fun/wonder_twins.yaml (renamed from bot/resources/evergreen/wonder_twins.yaml) | 0 | ||||
-rw-r--r-- | bot/resources/fun/xkcd_colours.json (renamed from bot/resources/evergreen/xkcd_colours.json) | 0 |
34 files changed, 16 insertions, 36 deletions
diff --git a/bot/exts/evergreen/__init__.py b/bot/exts/fun/__init__.py index e69de29b..e69de29b 100644 --- a/bot/exts/evergreen/__init__.py +++ b/bot/exts/fun/__init__.py diff --git a/bot/exts/evergreen/battleship.py b/bot/exts/fun/battleship.py index f4351954..f4351954 100644 --- a/bot/exts/evergreen/battleship.py +++ b/bot/exts/fun/battleship.py diff --git a/bot/exts/evergreen/catify.py b/bot/exts/fun/catify.py index 32dfae09..32dfae09 100644 --- a/bot/exts/evergreen/catify.py +++ b/bot/exts/fun/catify.py diff --git a/bot/exts/evergreen/coinflip.py b/bot/exts/fun/coinflip.py index 804306bd..804306bd 100644 --- a/bot/exts/evergreen/coinflip.py +++ b/bot/exts/fun/coinflip.py diff --git a/bot/exts/evergreen/connect_four.py b/bot/exts/fun/connect_four.py index 647bb2b7..647bb2b7 100644 --- a/bot/exts/evergreen/connect_four.py +++ b/bot/exts/fun/connect_four.py diff --git a/bot/exts/evergreen/duck_game.py b/bot/exts/fun/duck_game.py index d592f3df..1ef7513f 100644 --- a/bot/exts/evergreen/duck_game.py +++ b/bot/exts/fun/duck_game.py @@ -5,7 +5,6 @@ from collections import defaultdict from io import BytesIO from itertools import product from pathlib import Path -from urllib.parse import urlparse import discord from PIL import Image, ImageDraw, ImageFont @@ -15,7 +14,6 @@ from bot.bot import Bot from bot.constants import Colours, MODERATION_ROLES from bot.utils.decorators import with_role - DECK = list(product(*[(0, 1, 2)]*4)) GAME_DURATION = 180 @@ -33,9 +31,9 @@ INCORRECT_GOOSE = -1 SOLN_DISTR = 0, 0.05, 0.05, 0.1, 0.15, 0.25, 0.2, 0.15, .05 -IMAGE_PATH = Path("bot", "resources", "evergreen", "all_cards.png") -FONT_PATH = Path("bot", "resources", "evergreen", "LuckiestGuy-Regular.ttf") -HELP_IMAGE_PATH = Path("bot", "resources", "evergreen", "ducks_help_ex.png") +IMAGE_PATH = Path("bot", "resources", "fun", "all_cards.png") +FONT_PATH = Path("bot", "resources", "fun", "LuckiestGuy-Regular.ttf") +HELP_IMAGE_PATH = Path("bot", "resources", "fun", "ducks_help_ex.png") ALL_CARDS = Image.open(IMAGE_PATH) LABEL_FONT = ImageFont.truetype(str(FONT_PATH), size=16) @@ -193,6 +191,7 @@ class DuckGamesDirector(commands.Cog): game.running = True self.current_games[ctx.channel.id] = game + game.msg_content = "" game.embed_msg = await self.send_board_embed(ctx, game) await asyncio.sleep(GAME_DURATION) @@ -261,7 +260,6 @@ class DuckGamesDirector(commands.Cog): embed = discord.Embed( title="Duck Duck Duck Goose!", color=Colours.bright_green, - footer="" ) embed.set_image(url="attachment://board.png") return await ctx.send(embed=embed, file=file) @@ -269,12 +267,11 @@ class DuckGamesDirector(commands.Cog): async def display_claimed_answer(self, game: DuckGame, author: discord.Member, answer: tuple[int]) -> None: """Add a claimed answer to the game embed.""" async with game.editing_embed: - game_embed, = game.embed_msg.embeds - old_footer = game_embed.footer.text - if old_footer == discord.Embed.Empty: - old_footer = "" - game_embed.set_footer(text=f"{old_footer}\n{str(answer):12s} - {author.display_name}") - await self.edit_embed_with_image(game.embed_msg, game_embed) + # We specifically edit the message contents instead of the embed + # Because we load in the image from the file, editing any portion of the embed + # Does weird things to the image and this works around that weirdness + game.msg_content = f"{game.msg_content}\n{str(answer):12s} - {author.display_name}" + await game.embed_msg.edit(content=game.msg_content) async def end_game(self, channel: discord.TextChannel, game: DuckGame, end_message: str) -> None: """Edit the game embed to reflect the end of the game and mark the game as not running.""" @@ -300,17 +297,7 @@ class DuckGamesDirector(commands.Cog): else: missed_text = "All the flights were found!" - game_embed, = game.embed_msg.embeds - old_footer = game_embed.footer.text - if old_footer == discord.Embed.Empty: - old_footer = "" - embed_as_dict = game_embed.to_dict() # Cannot set embed color after initialization - embed_as_dict["color"] = discord.Color.red().value - game_embed = discord.Embed.from_dict(embed_as_dict) - game_embed.set_footer( - text=f"{old_footer.rstrip()}\n\n{missed_text}" - ) - await self.edit_embed_with_image(game.embed_msg, game_embed) + await game.embed_msg.edit(content=f"{missed_text}") @start_game.command(name="help") async def show_rules(self, ctx: commands.Context) -> None: @@ -343,13 +330,6 @@ class DuckGamesDirector(commands.Cog): ) return await ctx.send(file=file, embed=embed) - @staticmethod - async def edit_embed_with_image(msg: discord.Message, embed: discord.Embed) -> None: - """Edit an embed without the attached image going wonky.""" - attach_name = urlparse(embed.image.url).path.split("/")[-1] - embed.set_image(url=f"attachment://{attach_name}") - await msg.edit(embed=embed) - def setup(bot: Bot) -> None: """Load the DuckGamesDirector cog.""" diff --git a/bot/exts/evergreen/fun.py b/bot/exts/fun/fun.py index 4bbfe859..b148f1f3 100644 --- a/bot/exts/evergreen/fun.py +++ b/bot/exts/fun/fun.py @@ -57,7 +57,7 @@ class Fun(Cog): def __init__(self, bot: Bot): self.bot = bot - self._caesar_cipher_embed = json.loads(Path("bot/resources/evergreen/caesar_info.json").read_text("UTF-8")) + self._caesar_cipher_embed = json.loads(Path("bot/resources/fun/caesar_info.json").read_text("UTF-8")) @staticmethod def _get_random_die() -> str: diff --git a/bot/exts/evergreen/game.py b/bot/exts/fun/game.py index f9c150e6..f9c150e6 100644 --- a/bot/exts/evergreen/game.py +++ b/bot/exts/fun/game.py diff --git a/bot/exts/evergreen/magic_8ball.py b/bot/exts/fun/magic_8ball.py index 28ddcea0..a7b682ca 100644 --- a/bot/exts/evergreen/magic_8ball.py +++ b/bot/exts/fun/magic_8ball.py @@ -9,7 +9,7 @@ from bot.bot import Bot log = logging.getLogger(__name__) -ANSWERS = json.loads(Path("bot/resources/evergreen/magic8ball.json").read_text("utf8")) +ANSWERS = json.loads(Path("bot/resources/fun/magic8ball.json").read_text("utf8")) class Magic8ball(commands.Cog): diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/fun/minesweeper.py index a48b5051..a48b5051 100644 --- a/bot/exts/evergreen/minesweeper.py +++ b/bot/exts/fun/minesweeper.py diff --git a/bot/exts/evergreen/movie.py b/bot/exts/fun/movie.py index a04eeb41..a04eeb41 100644 --- a/bot/exts/evergreen/movie.py +++ b/bot/exts/fun/movie.py diff --git a/bot/exts/evergreen/recommend_game.py b/bot/exts/fun/recommend_game.py index bdd3acb1..42c9f7c2 100644 --- a/bot/exts/evergreen/recommend_game.py +++ b/bot/exts/fun/recommend_game.py @@ -12,7 +12,7 @@ log = logging.getLogger(__name__) game_recs = [] # Populate the list `game_recs` with resource files -for rec_path in Path("bot/resources/evergreen/game_recs").glob("*.json"): +for rec_path in Path("bot/resources/fun/game_recs").glob("*.json"): data = json.loads(rec_path.read_text("utf8")) game_recs.append(data) shuffle(game_recs) diff --git a/bot/exts/evergreen/rps.py b/bot/exts/fun/rps.py index c6bbff46..c6bbff46 100644 --- a/bot/exts/evergreen/rps.py +++ b/bot/exts/fun/rps.py diff --git a/bot/exts/evergreen/space.py b/bot/exts/fun/space.py index 48ad0f96..48ad0f96 100644 --- a/bot/exts/evergreen/space.py +++ b/bot/exts/fun/space.py diff --git a/bot/exts/evergreen/speedrun.py b/bot/exts/fun/speedrun.py index 774eff81..c2966ce1 100644 --- a/bot/exts/evergreen/speedrun.py +++ b/bot/exts/fun/speedrun.py @@ -9,7 +9,7 @@ from bot.bot import Bot log = logging.getLogger(__name__) -LINKS = json.loads(Path("bot/resources/evergreen/speedrun_links.json").read_text("utf8")) +LINKS = json.loads(Path("bot/resources/fun/speedrun_links.json").read_text("utf8")) class Speedrun(commands.Cog): diff --git a/bot/exts/evergreen/status_codes.py b/bot/exts/fun/status_codes.py index 501cbe0a..501cbe0a 100644 --- a/bot/exts/evergreen/status_codes.py +++ b/bot/exts/fun/status_codes.py diff --git a/bot/exts/evergreen/tic_tac_toe.py b/bot/exts/fun/tic_tac_toe.py index 5c4f8051..5c4f8051 100644 --- a/bot/exts/evergreen/tic_tac_toe.py +++ b/bot/exts/fun/tic_tac_toe.py diff --git a/bot/exts/evergreen/trivia_quiz.py b/bot/exts/fun/trivia_quiz.py index aa4020d6..cf9e6cd3 100644 --- a/bot/exts/evergreen/trivia_quiz.py +++ b/bot/exts/fun/trivia_quiz.py @@ -217,7 +217,7 @@ class TriviaQuiz(commands.Cog): @staticmethod def load_questions() -> dict: """Load the questions from the JSON file.""" - p = Path("bot", "resources", "evergreen", "trivia_quiz.json") + p = Path("bot", "resources", "fun", "trivia_quiz.json") return json.loads(p.read_text(encoding="utf-8")) diff --git a/bot/exts/evergreen/wonder_twins.py b/bot/exts/fun/wonder_twins.py index 40edf785..79d6b6d9 100644 --- a/bot/exts/evergreen/wonder_twins.py +++ b/bot/exts/fun/wonder_twins.py @@ -11,7 +11,7 @@ class WonderTwins(Cog): """Cog for a Wonder Twins inspired command.""" def __init__(self): - with open(Path.cwd() / "bot" / "resources" / "evergreen" / "wonder_twins.yaml", "r", encoding="utf-8") as f: + with open(Path.cwd() / "bot" / "resources" / "fun" / "wonder_twins.yaml", "r", encoding="utf-8") as f: info = yaml.load(f, Loader=yaml.FullLoader) self.water_types = info["water_types"] self.objects = info["objects"] diff --git a/bot/exts/evergreen/xkcd.py b/bot/exts/fun/xkcd.py index b56c53d9..b56c53d9 100644 --- a/bot/exts/evergreen/xkcd.py +++ b/bot/exts/fun/xkcd.py diff --git a/bot/resources/evergreen/LuckiestGuy-Regular.ttf b/bot/resources/fun/LuckiestGuy-Regular.ttf Binary files differindex 8c79c875..8c79c875 100644 --- a/bot/resources/evergreen/LuckiestGuy-Regular.ttf +++ b/bot/resources/fun/LuckiestGuy-Regular.ttf diff --git a/bot/resources/evergreen/all_cards.png b/bot/resources/fun/all_cards.png Binary files differindex 10ed2eb8..10ed2eb8 100644 --- a/bot/resources/evergreen/all_cards.png +++ b/bot/resources/fun/all_cards.png diff --git a/bot/resources/evergreen/caesar_info.json b/bot/resources/fun/caesar_info.json index 8229c4f3..8229c4f3 100644 --- a/bot/resources/evergreen/caesar_info.json +++ b/bot/resources/fun/caesar_info.json diff --git a/bot/resources/evergreen/ducks_help_ex.png b/bot/resources/fun/ducks_help_ex.png Binary files differindex 01d9c243..01d9c243 100644 --- a/bot/resources/evergreen/ducks_help_ex.png +++ b/bot/resources/fun/ducks_help_ex.png diff --git a/bot/resources/evergreen/game_recs/chrono_trigger.json b/bot/resources/fun/game_recs/chrono_trigger.json index 9720b977..9720b977 100644 --- a/bot/resources/evergreen/game_recs/chrono_trigger.json +++ b/bot/resources/fun/game_recs/chrono_trigger.json diff --git a/bot/resources/evergreen/game_recs/digimon_world.json b/bot/resources/fun/game_recs/digimon_world.json index c1cb4f37..c1cb4f37 100644 --- a/bot/resources/evergreen/game_recs/digimon_world.json +++ b/bot/resources/fun/game_recs/digimon_world.json diff --git a/bot/resources/evergreen/game_recs/doom_2.json b/bot/resources/fun/game_recs/doom_2.json index b60cc05f..b60cc05f 100644 --- a/bot/resources/evergreen/game_recs/doom_2.json +++ b/bot/resources/fun/game_recs/doom_2.json diff --git a/bot/resources/evergreen/game_recs/skyrim.json b/bot/resources/fun/game_recs/skyrim.json index ad86db31..ad86db31 100644 --- a/bot/resources/evergreen/game_recs/skyrim.json +++ b/bot/resources/fun/game_recs/skyrim.json diff --git a/bot/resources/evergreen/html_colours.json b/bot/resources/fun/html_colours.json index 086083d6..086083d6 100644 --- a/bot/resources/evergreen/html_colours.json +++ b/bot/resources/fun/html_colours.json diff --git a/bot/resources/evergreen/magic8ball.json b/bot/resources/fun/magic8ball.json index f5f1df62..f5f1df62 100644 --- a/bot/resources/evergreen/magic8ball.json +++ b/bot/resources/fun/magic8ball.json diff --git a/bot/resources/evergreen/speedrun_links.json b/bot/resources/fun/speedrun_links.json index acb5746a..acb5746a 100644 --- a/bot/resources/evergreen/speedrun_links.json +++ b/bot/resources/fun/speedrun_links.json diff --git a/bot/resources/evergreen/trivia_quiz.json b/bot/resources/fun/trivia_quiz.json index 8008838c..8008838c 100644 --- a/bot/resources/evergreen/trivia_quiz.json +++ b/bot/resources/fun/trivia_quiz.json diff --git a/bot/resources/evergreen/wonder_twins.yaml b/bot/resources/fun/wonder_twins.yaml index 05e8d749..05e8d749 100644 --- a/bot/resources/evergreen/wonder_twins.yaml +++ b/bot/resources/fun/wonder_twins.yaml diff --git a/bot/resources/evergreen/xkcd_colours.json b/bot/resources/fun/xkcd_colours.json index 3feeb639..3feeb639 100644 --- a/bot/resources/evergreen/xkcd_colours.json +++ b/bot/resources/fun/xkcd_colours.json |