From c5de4b0e6f548c60b2ffa131c7ba8b43125554da Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:30:17 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/build.yml | 1 - cogs/docs/pagination.py | 7 ++- cogs/feedback.py | 108 +++++++++++++++++++--------------- cogs/games/views/blackjack.py | 12 ++-- cogs/games/views/snake.py | 48 +++++---------- cogs/help/cog.py | 40 ++++++++----- cogs/moderation.py | 14 +++-- cogs/music/dcutils.py | 16 ++--- cogs/utils/cog.py | 5 +- core/utils/utils.py | 5 +- pyproject.toml | 2 +- 11 files changed, 131 insertions(+), 127 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 582244a..d073015 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,4 +20,3 @@ jobs: run: python main.py - name: Run tests run: pytest tests/ - \ No newline at end of file diff --git a/cogs/docs/pagination.py b/cogs/docs/pagination.py index 204c30c..90de876 100644 --- a/cogs/docs/pagination.py +++ b/cogs/docs/pagination.py @@ -130,9 +130,10 @@ def fill_items(self) -> None: self.add_item(self.numbered_page) self.add_item(self.stop_pages) - async def _get_kwargs_from_page( - self, page: int - ) -> Dict[str, Any,]: + async def _get_kwargs_from_page(self, page: int) -> Dict[ + str, + Any, + ]: value = await disnake.utils.maybe_coroutine(self.source.format_page, self, page) if isinstance(value, dict): return value diff --git a/cogs/feedback.py b/cogs/feedback.py index ee236fc..df73ff0 100644 --- a/cogs/feedback.py +++ b/cogs/feedback.py @@ -38,53 +38,67 @@ async def viewfeedback( str, ] = None, ): - await send_embed( - ctx, - "", - "**Error: **distance must be an integer (an index placevalue) if no `author_from` is given!", - ) if hasattr(distance, "upper") and author_from is None else await send_embed( - ctx, - "", - f'*`{distance}`*: "{data["feedback"]["message"][distance]}", submitted by **{data["feedback"]["author"][distance]}**' - if distance != 0 - else f"**You can index off of the index on the left side. Type `{ctx.prefix}viewfeedback `\n**\n" - + "\n".join( - [ - f"`{num}:` {data['feedback']['message'][k]}**, said by {data['feedback']['author'][k]}**" - for num, k in enumerate(range(len(data["feedback"]["message"]))) - if num <= 9 - ] - ), - a="Feedback", - i_u=ctx.author.display_avatar.url, - ) if author_from is None else await send_embed( - ctx, - "", - "\n".join( - [ - f"`{num}`: {data['feedback']['message'][num]}" - for num, k in enumerate(data["feedback"]["author"]) - if k == author_from - ] - ), - a=f"Feedback from {author_from}", - i_u=ctx.author.display_avatar.url, - f=f"All these messges are from {author_from}", - ) if hasattr( - author_from, "upper" - ) else await send_embed( - ctx, - "", - "\n".join( - [ - f"`{num}`: {data['feedback']['message'][num]}" - for num, k in enumerate(data["feedback"]["id"]) - if k == author_from - ] - ), - a=f"Feedback from {await self.bot.fetch_user(author_from)}", - i_u=ctx.author.display_avatar.url, - f=f"All these messages are from {await self.bot.fetch_user(author_from)}", + ( + await send_embed( + ctx, + "", + "**Error: **distance must be an integer (an index placevalue) if no `author_from` is given!", + ) + if hasattr(distance, "upper") and author_from is None + else ( + await send_embed( + ctx, + "", + ( + f'*`{distance}`*: "{data["feedback"]["message"][distance]}", submitted by **{data["feedback"]["author"][distance]}**' + if distance != 0 + else f"**You can index off of the index on the left side. Type `{ctx.prefix}viewfeedback `\n**\n" + + "\n".join( + [ + f"`{num}:` {data['feedback']['message'][k]}**, said by {data['feedback']['author'][k]}**" + for num, k in enumerate( + range(len(data["feedback"]["message"])) + ) + if num <= 9 + ] + ) + ), + a="Feedback", + i_u=ctx.author.display_avatar.url, + ) + if author_from is None + else ( + await send_embed( + ctx, + "", + "\n".join( + [ + f"`{num}`: {data['feedback']['message'][num]}" + for num, k in enumerate(data["feedback"]["author"]) + if k == author_from + ] + ), + a=f"Feedback from {author_from}", + i_u=ctx.author.display_avatar.url, + f=f"All these messges are from {author_from}", + ) + if hasattr(author_from, "upper") + else await send_embed( + ctx, + "", + "\n".join( + [ + f"`{num}`: {data['feedback']['message'][num]}" + for num, k in enumerate(data["feedback"]["id"]) + if k == author_from + ] + ), + a=f"Feedback from {await self.bot.fetch_user(author_from)}", + i_u=ctx.author.display_avatar.url, + f=f"All these messages are from {await self.bot.fetch_user(author_from)}", + ) + ) + ) ) @commands.command(aliases=["dial", "call", "assistance"]) diff --git a/cogs/games/views/blackjack.py b/cogs/games/views/blackjack.py index 43a0737..c973db5 100644 --- a/cogs/games/views/blackjack.py +++ b/cogs/games/views/blackjack.py @@ -89,11 +89,13 @@ def visual_hand(self, cards: List[Card] = None, hide_card: bool = False) -> str: player=player, bar="".join("-" for _ in range(len(player))), cards=visual_cards, - value=self.generate_card_values( - self.user_cards if not cards else self.bot_cards - ) - if not hide_card - else f"{cards[0].value} + ?", + value=( + self.generate_card_values( + self.user_cards if not cards else self.bot_cards + ) + if not hide_card + else f"{cards[0].value} + ?" + ), ) def generate_card_values(self, cards: List[Card]) -> int: diff --git a/cogs/games/views/snake.py b/cogs/games/views/snake.py index 1ca37ae..9e16f71 100644 --- a/cogs/games/views/snake.py +++ b/cogs/games/views/snake.py @@ -182,32 +182,25 @@ async def move_snake(self) -> None: await self.edit_embed(self.board) @_p1 - async def _pl_1(self, _, __): - ... + async def _pl_1(self, _, __): ... @_p1 - async def _pl_2(self, _, __): - ... + async def _pl_2(self, _, __): ... @_p1 - async def _pl_3(self, _, __): - ... + async def _pl_3(self, _, __): ... @_p1 - async def _pl_4(self, _, __): - ... + async def _pl_4(self, _, __): ... @_p1 - async def _pl_5(self, _, __): - ... + async def _pl_5(self, _, __): ... @_p2 - async def _pl_6(self, _, __): - ... + async def _pl_6(self, _, __): ... @_p2 - async def _pl_7(self, _, __): - ... + async def _pl_7(self, _, __): ... @button(style=ButtonStyle.green, emoji=UP_ARROW, disabled=True) async def up(self, button: Button, interaction: MessageInteraction) -> None: @@ -219,16 +212,13 @@ async def up(self, button: Button, interaction: MessageInteraction) -> None: await interaction.response.defer() @_p2 - async def _pl_8(self, _, __): - ... + async def _pl_8(self, _, __): ... @_p2 - async def _pl_9(self, _, __): - ... + async def _pl_9(self, _, __): ... @_p3 - async def _pl_10(self, _, __): - ... + async def _pl_10(self, _, __): ... @button(style=ButtonStyle.green, emoji=LEFT_ARROW, disabled=True, row=2) async def left(self, button: Button, interaction: MessageInteraction) -> None: @@ -258,28 +248,22 @@ async def right(self, button: Button, interaction: MessageInteraction) -> None: await interaction.response.defer() @_p3 - async def _pl_11(self, _, __): - ... + async def _pl_11(self, _, __): ... @_p4 - async def _pl_12(self, _, __): - ... + async def _pl_12(self, _, __): ... @_p4 - async def _pl_13(self, _, __): - ... + async def _pl_13(self, _, __): ... @_p4 - async def _pl_14(self, _, __): - ... + async def _pl_14(self, _, __): ... @_p4 - async def _pl_15(self, _, __): - ... + async def _pl_15(self, _, __): ... @_p4 - async def _pl_16(self, _, __): - ... + async def _pl_16(self, _, __): ... @button(label="Play", style=ButtonStyle.green, emoji=PLAY_BUTTON, row=4) async def play(self, button: Button, interaction: MessageInteraction) -> None: diff --git a/cogs/help/cog.py b/cogs/help/cog.py index abc445e..ac27e0e 100644 --- a/cogs/help/cog.py +++ b/cogs/help/cog.py @@ -89,23 +89,29 @@ async def specific_command( ) .add_field( name=" ❯❯ Alias", - value=f"{', '.join(f'`{k}`' for k in command.aliases if command.aliases)} " - if command.aliases - else "`none`", + value=( + f"{', '.join(f'`{k}`' for k in command.aliases if command.aliases)} " + if command.aliases + else "`none`" + ), inline=False, ) .add_field( name=" ❯❯ Usage", - value=f"`j.{command.name} {command.signature}`" - if command.signature - else f"`j.{command.name}`", + value=( + f"`j.{command.name} {command.signature}`" + if command.signature + else f"`j.{command.name}`" + ), inline=False, ) .add_field( name=" ❯❯ Description", - value=f"{get_help(command.name)}" - if get_help(command.name) - else "Currently no help!", + value=( + f"{get_help(command.name)}" + if get_help(command.name) + else "Currently no help!" + ), inline=False, ) .set_author(name="Help", icon_url=ctx.author.display_avatar.url) @@ -152,15 +158,19 @@ async def no_command(self, ctx: Context) -> disnake.Embed: ) .add_field( name="\u200b", - value="\n".join(commands[i] for i in range(0, len(commands), 2)) - if commands - else "-", + value=( + "\n".join(commands[i] for i in range(0, len(commands), 2)) + if commands + else "-" + ), ) .add_field( name="\u200b", - value="\n".join(commands[i] for i in range(1, len(commands), 2)) - if commands - else "-", + value=( + "\n".join(commands[i] for i in range(1, len(commands), 2)) + if commands + else "-" + ), ) ) diff --git a/cogs/moderation.py b/cogs/moderation.py index 062f503..3518e1c 100644 --- a/cogs/moderation.py +++ b/cogs/moderation.py @@ -111,7 +111,7 @@ async def ban( try: await member.send("You have been banned: " + reason) except HTTPException: - await ctx.send("Could message user") + await ctx.send("Could message user") await member.ban(reason=reason) embed = disnake.Embed( title="Banned", @@ -137,7 +137,7 @@ async def unban(self, ctx: Context, user_id: int, *, reason="No reason provided" try: await user.send(f"You have been unbanned from {ctx.guild.name}") except HTTPException: - await ctx.send("Could message user") + await ctx.send("Could message user") @has_permissions(manage_roles=True) @commands.command(aliases=["add", "+role", "add_role"]) @@ -301,9 +301,11 @@ async def permmute(self, ctx: Context, member: disnake.Member, *, reason=None): await ctx.reply(embed=embed) await member.add_roles(mutedRole, reason=reason) try: - await member.send(f" you have been muted from: {guild.name} Reason: {reason}") + await member.send( + f" you have been muted from: {guild.name} Reason: {reason}" + ) except HTTPException: - await ctx.send("Could message user") + await ctx.send("Could message user") @commands.command( aliases=["unrmute", "runmute"], description="Unreactmutes ``" @@ -336,7 +338,7 @@ async def unreactmute(self, ctx: Context, member: disnake.Member, *, reason=None f"You have been reaction muted from: {guild.name} Reason: {reason}" ) except HTTPException: - await ctx.send("Could message user") + await ctx.send("Could message user") @commands.command(aliases=["unmut"], description="Unmutes ``") @has_permissions(manage_messages=True) @@ -366,7 +368,7 @@ async def unmute(self, ctx: Context, member: disnake.Member, *, reason=None): f"You have been reaction muted from: {guild.name} Reason: {reason}" ) except HTTPException: - await ctx.send("Could message user") + await ctx.send("Could message user") @commands.command( aliases=["tempmute"], diff --git a/cogs/music/dcutils.py b/cogs/music/dcutils.py index 1e6368e..b3e5c1e 100644 --- a/cogs/music/dcutils.py +++ b/cogs/music/dcutils.py @@ -248,19 +248,11 @@ def __init__(self, ctx, music, **kwargs): if self.ctx.guild.id not in self.music.queue.keys(): self.music.queue[self.ctx.guild.id] = [] self.after_func = check_queue - self.on_play_func = ( - self.on_queue_func - ) = ( - self.on_skip_func - ) = ( + self.on_play_func = self.on_queue_func = self.on_skip_func = ( self.on_stop_func - ) = ( - self.on_pause_func - ) = ( - self.on_resume_func - ) = ( - self.on_loop_toggle_func - ) = self.on_volume_change_func = self.on_remove_from_queue_func = None + ) = self.on_pause_func = self.on_resume_func = self.on_loop_toggle_func = ( + self.on_volume_change_func + ) = self.on_remove_from_queue_func = None ffmpeg_error = kwargs.get( "ffmpeg_error_betterfix", kwargs.get("ffmpeg_error_fix") ) diff --git a/cogs/utils/cog.py b/cogs/utils/cog.py index 3478776..efc4893 100644 --- a/cogs/utils/cog.py +++ b/cogs/utils/cog.py @@ -139,7 +139,10 @@ async def charinfo(self, ctx: Context, *, characters: str): def get_info( char: str, - ) -> Tuple[str, str,]: + ) -> Tuple[ + str, + str, + ]: digit = f"{ord(char):x}" if len(digit) <= 4: u_code = f"\\u{digit:>04}" diff --git a/core/utils/utils.py b/core/utils/utils.py index 0157f2c..a293e05 100644 --- a/core/utils/utils.py +++ b/core/utils/utils.py @@ -20,10 +20,7 @@ def get_colour() -> int: async def send_embed( - channel: disnake.abc.Messageable, - title: str, - description: str = None, - **kwargs + channel: disnake.abc.Messageable, title: str, description: str = None, **kwargs ) -> disnake.Message: from core.context import Context diff --git a/pyproject.toml b/pyproject.toml index 8c4eaa6..75fc7c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ [tool.ruff] ignore = [ "F401" -] \ No newline at end of file +]