diff options
author | 2021-05-15 17:32:09 -0400 | |
---|---|---|
committer | 2021-05-15 17:32:09 -0400 | |
commit | 8ac335afc7466d92888c40db46e0c6d454743ff6 (patch) | |
tree | c712cc52148baf9e6613aa6485d05858596ed3fa | |
parent | chore: Resolve conflicts for the last time (hopefully) (diff) |
chore: Add Iceman's suggested changes
-rw-r--r-- | bot/exts/easter/bunny_name_generator.py | 9 | ||||
-rw-r--r-- | bot/exts/easter/easter_riddle.py | 2 | ||||
-rw-r--r-- | bot/exts/easter/egg_facts.py | 3 | ||||
-rw-r--r-- | bot/exts/evergreen/avatar_modification/_effects.py | 4 | ||||
-rw-r--r-- | bot/exts/evergreen/avatar_modification/avatar_modify.py | 4 | ||||
-rw-r--r-- | bot/exts/evergreen/battleship.py | 8 |
6 files changed, 17 insertions, 13 deletions
diff --git a/bot/exts/easter/bunny_name_generator.py b/bot/exts/easter/bunny_name_generator.py index adde8704..3e97373f 100644 --- a/bot/exts/easter/bunny_name_generator.py +++ b/bot/exts/easter/bunny_name_generator.py @@ -17,14 +17,16 @@ BUNNY_NAMES = json.loads(Path("bot/resources/easter/bunny_names.json").read_text class BunnyNameGenerator(commands.Cog): """Generate a random bunny name, or bunnify your Discord username!""" - def find_separators(self, displayname: str) -> Union[List[str], None]: + @staticmethod + def find_separators(displayname: str) -> Union[List[str], None]: """Check if Discord name contains spaces so we can bunnify an individual word in the name.""" new_name = re.split(r"[_.\s]", displayname) if displayname not in new_name: return new_name return None - def find_vowels(self, displayname: str) -> str: + @staticmethod + def find_vowels(displayname: str) -> str: """ Finds vowels in the user's display name. @@ -45,7 +47,8 @@ class BunnyNameGenerator(commands.Cog): if new_name != displayname: return new_name - def append_name(self, displayname: str) -> str: + @staticmethod + def append_name(displayname: str) -> str: """Adds a suffix to the end of the Discord name.""" extensions = ["foot", "ear", "nose", "tail"] suffix = random.choice(extensions) diff --git a/bot/exts/easter/easter_riddle.py b/bot/exts/easter/easter_riddle.py index a87f93d1..88b3be2f 100644 --- a/bot/exts/easter/easter_riddle.py +++ b/bot/exts/easter/easter_riddle.py @@ -48,7 +48,7 @@ class EasterRiddle(commands.Cog): ) return - self.current_channel = ctx.message.channel + self.current_channel = ctx.channel random_question = random.choice(RIDDLE_QUESTIONS) question = random_question["question"] diff --git a/bot/exts/easter/egg_facts.py b/bot/exts/easter/egg_facts.py index ee383171..486e735f 100644 --- a/bot/exts/easter/egg_facts.py +++ b/bot/exts/easter/egg_facts.py @@ -40,7 +40,8 @@ class EasterFacts(commands.Cog): embed = self.make_embed() await ctx.send(embed=embed) - def make_embed(self) -> discord.Embed: + @staticmethod + def make_embed() -> discord.Embed: """Makes a nice embed for the message to be sent.""" return discord.Embed( colour=Colours.soft_red, diff --git a/bot/exts/evergreen/avatar_modification/_effects.py b/bot/exts/evergreen/avatar_modification/_effects.py index 9339ecc4..cd798fc2 100644 --- a/bot/exts/evergreen/avatar_modification/_effects.py +++ b/bot/exts/evergreen/avatar_modification/_effects.py @@ -14,7 +14,7 @@ class PfpEffects: """ Implements various image modifying effects, for the PfpModify cog. - All of these fuctions are slow, and blocking, so they should be ran in executors. + All of these functions are slow, and blocking, so they should be ran in executors. """ @staticmethod @@ -102,7 +102,7 @@ class PfpEffects: Applies the easter effect to the given image. This is done by getting the closest "easter" colour to each pixel and changing the colour - to the half-way RGBvalue. + to the half-way RGB value. We also then add an overlay image on top in middle right, a chocolate bunny by default. """ diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 199b6dcb..17f34ed4 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -33,7 +33,7 @@ GENDER_OPTIONS = json.loads(Path("bot/resources/pride/gender_options.json").read async def in_executor(func: t.Callable[..., T], *args) -> T: """ - Runs the given synchronus function `func` in an executor. + Runs the given synchronous function `func` in an executor. This is useful for running slow, blocking code within async functions, so that they don't block the bot. @@ -71,7 +71,7 @@ class AvatarModify(commands.Cog): Fetches a user and handles errors. This helper function is required as the member cache doesn't always have the most up to date - profile picture. This can lead to errors if the image is delted from the Discord CDN. + profile picture. This can lead to errors if the image is deleted from the Discord CDN. fetch_member can't be used due to the avatar url being part of the user object, and some weird caching that D.py does """ diff --git a/bot/exts/evergreen/battleship.py b/bot/exts/evergreen/battleship.py index 27c50bdb..c2f2079c 100644 --- a/bot/exts/evergreen/battleship.py +++ b/bot/exts/evergreen/battleship.py @@ -31,8 +31,8 @@ EmojiSet = typing.Dict[typing.Tuple[bool, bool], str] class Player: """Each player in the game - their messages for the boards and their current grid.""" - user: discord.Member - board: discord.Message + user: typing.Optional[discord.Member] + board: typing.Optional[discord.Message] opponent_board: discord.Message grid: Grid @@ -417,9 +417,9 @@ class Battleship(commands.Cog): self.waiting.remove(ctx.author) if self.already_playing(ctx.author): return + game = Game(self.bot, ctx.channel, ctx.author, user) + self.games.append(game) try: - game = Game(self.bot, ctx.channel, ctx.author, user) - self.games.append(game) await game.start_game() self.games.remove(game) except discord.Forbidden: |