diff options
| author | 2021-05-14 12:34:30 -0400 | |
|---|---|---|
| committer | 2021-05-14 12:34:30 -0400 | |
| commit | 92c33d625068b9b39564dbf4fb9f6c1102711955 (patch) | |
| tree | 40ce3e18ff8df18cb09ca2c3b2c7f00fa7e5811a /bot/exts | |
| parent | chore: Break up the HelpSession.build_pages method (diff) | |
chore: Refactor more code to follow our style guide
Diffstat (limited to 'bot/exts')
| -rw-r--r-- | bot/exts/evergreen/avatar_modification/_effects.py | 6 | ||||
| -rw-r--r-- | bot/exts/evergreen/connect_four.py | 70 | ||||
| -rw-r--r-- | bot/exts/evergreen/game.py | 6 | ||||
| -rw-r--r-- | bot/exts/evergreen/issues.py | 16 | ||||
| -rw-r--r-- | bot/exts/evergreen/minesweeper.py | 12 | ||||
| -rw-r--r-- | bot/exts/evergreen/movie.py | 6 | ||||
| -rw-r--r-- | bot/exts/evergreen/snakes/_snakes_cog.py | 10 | ||||
| -rw-r--r-- | bot/exts/evergreen/snakes/_utils.py | 16 | ||||
| -rw-r--r-- | bot/exts/evergreen/wolfram.py | 16 | ||||
| -rw-r--r-- | bot/exts/halloween/candy_collection.py | 8 | ||||
| -rw-r--r-- | bot/exts/halloween/monstersurvey.py | 23 | ||||
| -rw-r--r-- | bot/exts/valentines/movie_generator.py | 6 | 
12 files changed, 108 insertions, 87 deletions
| diff --git a/bot/exts/evergreen/avatar_modification/_effects.py b/bot/exts/evergreen/avatar_modification/_effects.py index d2370b4b..9339ecc4 100644 --- a/bot/exts/evergreen/avatar_modification/_effects.py +++ b/bot/exts/evergreen/avatar_modification/_effects.py @@ -251,7 +251,7 @@ class PfpEffects:          total_width = multiplier * single_wdith          total_height = multiplier * single_height -        new_image = Image.new('RGBA', (total_width, total_height), (250, 250, 250)) +        new_image = Image.new("RGBA", (total_width, total_height), (250, 250, 250))          width_multiplier = 0          height = 0 @@ -275,13 +275,13 @@ class PfpEffects:      def mosaic_effect(img_bytes: bytes, squares: int, file_name: str) -> discord.File:          """Seperate function run from an executor which turns an image into a mosaic."""          avatar = Image.open(BytesIO(img_bytes)) -        avatar = avatar.convert('RGBA').resize((1024, 1024)) +        avatar = avatar.convert("RGBA").resize((1024, 1024))          img_squares = PfpEffects.split_image(avatar, squares)          new_img = PfpEffects.join_images(img_squares)          bufferedio = BytesIO() -        new_img.save(bufferedio, format='PNG') +        new_img.save(bufferedio, format="PNG")          bufferedio.seek(0)          return discord.File(bufferedio, filename=file_name) diff --git a/bot/exts/evergreen/connect_four.py b/bot/exts/evergreen/connect_four.py index dc365a70..7a39d442 100644 --- a/bot/exts/evergreen/connect_four.py +++ b/bot/exts/evergreen/connect_four.py @@ -22,13 +22,13 @@ class Game:      """A Connect 4 Game."""      def __init__( -            self, -            bot: Bot, -            channel: discord.TextChannel, -            player1: discord.Member, -            player2: typing.Optional[discord.Member], -            tokens: typing.List[str], -            size: int = 7 +        self, +        bot: Bot, +        channel: discord.TextChannel, +        player1: discord.Member, +        player2: typing.Optional[discord.Member], +        tokens: typing.List[str], +        size: int = 7      ) -> None:          self.bot = bot @@ -286,20 +286,20 @@ class ConnectFour(commands.Cog):          return True      def get_player( -            self, -            ctx: commands.Context, -            announcement: discord.Message, -            reaction: discord.Reaction, -            user: discord.Member +        self, +        ctx: commands.Context, +        announcement: discord.Message, +        reaction: discord.Reaction, +        user: discord.Member      ) -> bool:          """Predicate checking the criteria for the announcement message."""          if self.already_playing(ctx.author):  # If they've joined a game since requesting a player 2              return True  # Is dealt with later on          if ( -                user.id not in (ctx.me.id, ctx.author.id) -                and str(reaction.emoji) == Emojis.hand_raised -                and reaction.message.id == announcement.id +            user.id not in (ctx.me.id, ctx.author.id) +            and str(reaction.emoji) == Emojis.hand_raised +            and reaction.message.id == announcement.id          ):              if self.already_playing(user):                  self.bot.loop.create_task(ctx.send(f"{user.mention} You're already playing a game!")) @@ -316,9 +316,9 @@ class ConnectFour(commands.Cog):              return True          if ( -                user.id == ctx.author.id -                and str(reaction.emoji) == CROSS_EMOJI -                and reaction.message.id == announcement.id +            user.id == ctx.author.id +            and str(reaction.emoji) == CROSS_EMOJI +            and reaction.message.id == announcement.id          ):              return True          return False @@ -329,7 +329,7 @@ class ConnectFour(commands.Cog):      @staticmethod      def check_emojis( -            e1: EMOJI_CHECK, e2: EMOJI_CHECK +        e1: EMOJI_CHECK, e2: EMOJI_CHECK      ) -> typing.Tuple[bool, typing.Optional[str]]:          """Validate the emojis, the user put."""          if isinstance(e1, str) and emojis.count(e1) != 1: @@ -339,12 +339,12 @@ class ConnectFour(commands.Cog):          return True, None      async def _play_game( -            self, -            ctx: commands.Context, -            user: typing.Optional[discord.Member], -            board_size: int, -            emoji1: str, -            emoji2: str +        self, +        ctx: commands.Context, +        user: typing.Optional[discord.Member], +        board_size: int, +        emoji1: str, +        emoji2: str      ) -> None:          """Helper for playing a game of connect four."""          self.tokens = [":white_circle:", str(emoji1), str(emoji2)] @@ -369,11 +369,11 @@ class ConnectFour(commands.Cog):          case_insensitive=True      )      async def connect_four( -            self, -            ctx: commands.Context, -            board_size: int = 7, -            emoji1: EMOJI_CHECK = "\U0001f535", -            emoji2: EMOJI_CHECK = "\U0001f534" +        self, +        ctx: commands.Context, +        board_size: int = 7, +        emoji1: EMOJI_CHECK = "\U0001f535", +        emoji2: EMOJI_CHECK = "\U0001f534"      ) -> None:          """          Play the classic game of Connect Four with someone! @@ -430,11 +430,11 @@ class ConnectFour(commands.Cog):      @guild_only()      @connect_four.command(aliases=["bot", "computer", "cpu"])      async def ai( -            self, -            ctx: commands.Context, -            board_size: int = 7, -            emoji1: EMOJI_CHECK = "\U0001f535", -            emoji2: EMOJI_CHECK = "\U0001f534" +        self, +        ctx: commands.Context, +        board_size: int = 7, +        emoji1: EMOJI_CHECK = "\U0001f535", +        emoji2: EMOJI_CHECK = "\U0001f534"      ) -> None:          """Play Connect Four against a computer player."""          check, emoji = self.check_emojis(emoji1, emoji2) diff --git a/bot/exts/evergreen/game.py b/bot/exts/evergreen/game.py index 6f01d81c..43f64be7 100644 --- a/bot/exts/evergreen/game.py +++ b/bot/exts/evergreen/game.py @@ -374,8 +374,10 @@ class Games(Cog):          release_date = dt.utcfromtimestamp(data["first_release_date"]).date() if "first_release_date" in data else "?"          # Create Age Ratings value -        rating = ", ".join(f"{AgeRatingCategories(age['category']).name} {AgeRatings(age['rating']).name}" -                           for age in data["age_ratings"]) if "age_ratings" in data else "?" +        rating = ", ".join( +            f"{AgeRatingCategories(age['category']).name} {AgeRatings(age['rating']).name}" +            for age in data["age_ratings"] +        ) if "age_ratings" in data else "?"          companies = [c["company"]["name"] for c in data["involved_companies"]] if "involved_companies" in data else "?" diff --git a/bot/exts/evergreen/issues.py b/bot/exts/evergreen/issues.py index 5bbc57c6..b67aa4a6 100644 --- a/bot/exts/evergreen/issues.py +++ b/bot/exts/evergreen/issues.py @@ -162,9 +162,9 @@ class Issues(commands.Cog):      @staticmethod      def format_embed( -            results: t.List[t.Union[IssueState, FetchError]], -            user: str, -            repository: t.Optional[str] = None +        results: t.List[t.Union[IssueState, FetchError]], +        user: str, +        repository: t.Optional[str] = None      ) -> discord.Embed:          """Take a list of IssueState or FetchError and format a Discord embed for them."""          description_list = [] @@ -187,11 +187,11 @@ class Issues(commands.Cog):      @whitelist_override(channels=WHITELISTED_CHANNELS, categories=WHITELISTED_CATEGORIES)      @commands.command(aliases=("pr",))      async def issue( -            self, -            ctx: commands.Context, -            numbers: commands.Greedy[int], -            repository: str = "sir-lancebot", -            user: str = "python-discord" +        self, +        ctx: commands.Context, +        numbers: commands.Greedy[int], +        repository: str = "sir-lancebot", +        user: str = "python-discord"      ) -> None:          """Command to retrieve issue(s) from a GitHub repository."""          # Remove duplicates diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/evergreen/minesweeper.py index 7a31dfde..932358f9 100644 --- a/bot/exts/evergreen/minesweeper.py +++ b/bot/exts/evergreen/minesweeper.py @@ -212,12 +212,12 @@ class Minesweeper(commands.Cog):              return True      async def reveal_one( -            self, -            ctx: commands.Context, -            revealed: GameBoard, -            board: GameBoard, -            x: int, -            y: int +        self, +        ctx: commands.Context, +        revealed: GameBoard, +        board: GameBoard, +        x: int, +        y: int      ) -> bool:          """          Reveal one square. diff --git a/bot/exts/evergreen/movie.py b/bot/exts/evergreen/movie.py index fa284417..ff23df4c 100644 --- a/bot/exts/evergreen/movie.py +++ b/bot/exts/evergreen/movie.py @@ -79,8 +79,10 @@ class Movie(Cog):          # Check if "results" is in result. If not, throw error.          if "results" not in result: -            err_msg = f"There is problem while making TMDB API request. Response Code: {result['status_code']}, " \ -                      f"{result['status_message']}." +            err_msg = ( +                f"There is problem while making TMDB API request. Response Code: {result['status_code']}, " +                f"{result['status_message']}." +            )              await ctx.send(err_msg)              logger.warning(err_msg) diff --git a/bot/exts/evergreen/snakes/_snakes_cog.py b/bot/exts/evergreen/snakes/_snakes_cog.py index c50b23c5..07d3c363 100644 --- a/bot/exts/evergreen/snakes/_snakes_cog.py +++ b/bot/exts/evergreen/snakes/_snakes_cog.py @@ -579,9 +579,13 @@ class Snakes(Cog):              antidote_embed = Embed(color=SNAKE_COLOR, title="Antidote")              antidote_embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)              antidote_embed.set_image(url="https://media.giphy.com/media/ceeN6U57leAhi/giphy.gif") -            antidote_embed.add_field(name=EMPTY_UNICODE, -                                     value=f"Sorry you didnt make the antidote in time.\n" -                                           f"The formula was {' '.join(antidote_answer)}") +            antidote_embed.add_field( +                name=EMPTY_UNICODE, +                value=( +                    f"Sorry you didnt make the antidote in time.\n" +                    f"The formula was {' '.join(antidote_answer)}" +                ) +            )              await board_id.edit(embed=antidote_embed)          log.debug("Ending pagination and removing all reactions...") diff --git a/bot/exts/evergreen/snakes/_utils.py b/bot/exts/evergreen/snakes/_utils.py index 8b39f217..0a5894b7 100644 --- a/bot/exts/evergreen/snakes/_utils.py +++ b/bot/exts/evergreen/snakes/_utils.py @@ -17,38 +17,38 @@ from bot.constants import Roles  SNAKE_RESOURCES = Path("bot/resources/snakes").absolute() -h1 = r'''``` +h1 = r"""```          ----         ------       /--------\       |--------|       |--------|        \------/ -        ----```''' -h2 = r'''``` +        ----```""" +h2 = r"""```          ----         ------       /---\-/--\       |-----\--|       |--------|        \------/ -        ----```''' -h3 = r'''``` +        ----```""" +h3 = r"""```          ----         ------       /---\-/--\       |-----\--|       |-----/--|        \----\-/ -        ----```''' -h4 = r'''``` +        ----```""" +h4 = r"""```          -----         -----  \       /--|  /---\       |--\  -\---|       |--\--/--  /        \------- / -        ------```''' +        ------```"""  stages = [h1, h2, h3, h4]  snakes = {      "Baby Python": "https://i.imgur.com/SYOcmSa.png", diff --git a/bot/exts/evergreen/wolfram.py b/bot/exts/evergreen/wolfram.py index ca7d8454..d23afd6f 100644 --- a/bot/exts/evergreen/wolfram.py +++ b/bot/exts/evergreen/wolfram.py @@ -40,9 +40,11 @@ async def send_embed(      """Generate & send a response embed with Wolfram as the author."""      embed = Embed(colour=colour)      embed.description = message_txt -    embed.set_author(name="Wolfram Alpha", -                     icon_url=WOLF_IMAGE, -                     url="https://www.wolframalpha.com/") +    embed.set_author( +        name="Wolfram Alpha", +        icon_url=WOLF_IMAGE, +        url="https://www.wolframalpha.com/" +    )      if footer:          embed.set_footer(text=footer) @@ -222,9 +224,11 @@ class Wolfram(Cog):              return          embed = Embed() -        embed.set_author(name="Wolfram Alpha", -                         icon_url=WOLF_IMAGE, -                         url="https://www.wolframalpha.com/") +        embed.set_author( +            name="Wolfram Alpha", +            icon_url=WOLF_IMAGE, +            url="https://www.wolframalpha.com/" +        )          embed.colour = Colours.soft_orange          await ImagePaginator.paginate(pages, ctx, embed) diff --git a/bot/exts/halloween/candy_collection.py b/bot/exts/halloween/candy_collection.py index 14efa1fb..4afd5913 100644 --- a/bot/exts/halloween/candy_collection.py +++ b/bot/exts/halloween/candy_collection.py @@ -155,8 +155,12 @@ class CandyCollection(commands.Cog):      ) -> None:          """An alternative spooky message sent when user has no candies in the collection."""          embed = discord.Embed(color=author.color) -        embed.set_author(name="Ghosts and Ghouls and Jack o' lanterns at night; " -                              "I tried to take your candies but you had none to begin with!") +        embed.set_author( +            name=( +                "Ghosts and Ghouls and Jack o' lanterns at night; " +                "I tried to take your candies but you had none to begin with!" +            ) +        )          await channel.send(embed=embed)      @in_month(Month.OCTOBER) diff --git a/bot/exts/halloween/monstersurvey.py b/bot/exts/halloween/monstersurvey.py index 240a97db..96cda11e 100644 --- a/bot/exts/halloween/monstersurvey.py +++ b/bot/exts/halloween/monstersurvey.py @@ -71,7 +71,8 @@ class MonsterSurvey(Cog):                  default_embed.add_field(                      name=".monster show monster_name(optional)",                      value="Show a specific monster. If none is listed, it will give you an error with valid choices.", -                    inline=False) +                    inline=False +                )                  default_embed.add_field(                      name=".monster vote monster_name",                      value="Vote for a specific monster. You get one vote, but can change it at any time.", @@ -182,15 +183,17 @@ class MonsterSurvey(Cog):              for rank, m in enumerate(top):                  votes = len(vr[m]["votes"])                  percentage = ((votes / total_votes) * 100) if total_votes > 0 else 0 -                embed.add_field(name=f"{rank+1}. {vr[m]['full_name']}", -                                value=( -                                    f"{votes} votes. {percentage:.1f}% of total votes.\n" -                                    f"Vote for this monster by typing " -                                    f"'.monster vote {m}'\n" -                                    f"Get more information on this monster by typing " -                                    f"'.monster show {m}'" -                                ), -                                inline=False) +                embed.add_field( +                    name=f"{rank+1}. {vr[m]['full_name']}", +                    value=( +                        f"{votes} votes. {percentage:.1f}% of total votes.\n" +                        f"Vote for this monster by typing " +                        f"'.monster vote {m}'\n" +                        f"Get more information on this monster by typing " +                        f"'.monster show {m}'" +                    ), +                    inline=False +                )              embed.set_footer(text="You can also vote by their rank number. '.monster vote {number}' ") diff --git a/bot/exts/valentines/movie_generator.py b/bot/exts/valentines/movie_generator.py index 4508c3b2..0fc5edb4 100644 --- a/bot/exts/valentines/movie_generator.py +++ b/bot/exts/valentines/movie_generator.py @@ -54,8 +54,10 @@ class RomanceMovieFinder(commands.Cog):                  embed.set_thumbnail(url="https://i.imgur.com/LtFtC8H.png")                  await ctx.send(embed=embed)              except KeyError: -                warning_message = "A KeyError was raised while fetching information on the movie. The API service" \ -                                  " could be unavailable or the API key could be set incorrectly." +                warning_message = ( +                    "A KeyError was raised while fetching information on the movie. The API service" +                    " could be unavailable or the API key could be set incorrectly." +                )                  embed = discord.Embed(title=warning_message)                  log.warning(warning_message)                  await ctx.send(embed=embed) | 
