diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index 7547152..20bbc40 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -12,6 +12,7 @@ jobs: black: name: Python Black runs-on: ubuntu-latest + if: github.event.pull_request.head.repo.full_name == github.repository steps: - uses: actions/checkout@v3 @@ -47,3 +48,12 @@ jobs: git commit -m "Apply black formatting" git push + fork-black: + name: Python Black + runs-on: ubuntu-latest + if: github.event.pull_request.head.repo.full_name != github.repository + + steps: + - uses: actions/checkout@v3 + - uses: psf/black@stable + diff --git a/robocop_ng/__main__.py b/robocop_ng/__main__.py index c9d18fe..b41237f 100755 --- a/robocop_ng/__main__.py +++ b/robocop_ng/__main__.py @@ -47,7 +47,7 @@ wanted_jsons = [ "data/userlog.json", "data/invites.json", "data/macros.json", - "data/persistent_roles.json" + "data/persistent_roles.json", ] intents = discord.Intents.all() @@ -170,7 +170,7 @@ async def on_command_error(ctx, error): "to run this command in the current channel." ) elif isinstance(error, commands.CommandInvokeError) and ( - "Cannot send messages to this user" in error_text + "Cannot send messages to this user" in error_text ): return await ctx.send( f"{ctx.author.mention}: I can't DM you.\n" @@ -198,8 +198,8 @@ async def on_command_error(ctx, error): # and if said commands get used, add a specific notice. if ctx.command.name in ಠ_ಠ: help_text = ( - "This probably means that user left (or already got kicked/banned).\n" - + help_text + "This probably means that user left (or already got kicked/banned).\n" + + help_text ) return await ctx.send( @@ -223,7 +223,7 @@ async def on_message(message): # an allowed command welcome_allowed = ["reset", "kick", "ban", "warn"] if message.channel.id == config.welcome_channel and not any( - cmd in message.content for cmd in welcome_allowed + cmd in message.content for cmd in welcome_allowed ): return diff --git a/robocop_ng/cogs/err.py b/robocop_ng/cogs/err.py index 660d565..4103c0a 100644 --- a/robocop_ng/cogs/err.py +++ b/robocop_ng/cogs/err.py @@ -98,7 +98,6 @@ class Err(Cog): Usage: .serr/.nxerr/.err """ if self.switch_re.match(err) or err.startswith("0x"): # Switch - if err.startswith("0x"): err = err[2:] errcode = int(err, 16) diff --git a/robocop_ng/cogs/logs.py b/robocop_ng/cogs/logs.py index 560d4d0..0c17218 100644 --- a/robocop_ng/cogs/logs.py +++ b/robocop_ng/cogs/logs.py @@ -190,7 +190,8 @@ class Logs(Cog): # Show a message embed embed = discord.Embed(description=regd) embed.set_author( - name=message.author.display_name, icon_url=str(message.author.display_avatar) + name=message.author.display_name, + icon_url=str(message.author.display_avatar), ) await spy_channel.send(msg, embed=embed) diff --git a/robocop_ng/cogs/macro.py b/robocop_ng/cogs/macro.py index b179d17..32eb9c6 100644 --- a/robocop_ng/cogs/macro.py +++ b/robocop_ng/cogs/macro.py @@ -5,7 +5,13 @@ from discord.ext import commands from discord.ext.commands import Cog, Context, BucketType from robocop_ng.helpers.checks import check_if_staff -from robocop_ng.helpers.macros import get_macro, add_macro, edit_macro, remove_macro, get_macros +from robocop_ng.helpers.macros import ( + get_macro, + add_macro, + edit_macro, + remove_macro, + get_macros, +) class Macro(Cog): @@ -20,7 +26,9 @@ class Macro(Cog): else: await ctx.send(text) else: - await ctx.send(f"{ctx.author.mention}: The macro '{key}' doesn't exist.") + await ctx.send( + f"{ctx.author.mention}: The macro '{key}' doesn't exist." + ) @commands.check(check_if_staff) @commands.command(name="macroadd", aliases=["ma", "addmacro", "add_macro"]) @@ -39,9 +47,18 @@ class Macro(Cog): await ctx.send(f"Error: Macro '{key}' not found.") @commands.check(check_if_staff) - @commands.command(name="macroremove", aliases=[ - "mr", "md", "removemacro", "remove_macro", "macrodel", "delmacro", "delete_macro" - ]) + @commands.command( + name="macroremove", + aliases=[ + "mr", + "md", + "removemacro", + "remove_macro", + "macrodel", + "delmacro", + "delete_macro", + ], + ) async def remove_macro(self, ctx: Context, key: str): if remove_macro(key): await ctx.send(f"Macro '{key}' removed!") diff --git a/robocop_ng/cogs/mod.py b/robocop_ng/cogs/mod.py index c80c346..e73b628 100644 --- a/robocop_ng/cogs/mod.py +++ b/robocop_ng/cogs/mod.py @@ -730,9 +730,7 @@ class Mod(Cog): avatar_url = str(message.author.display_avatar) # set the embed message author to original author - embedMessage.set_author( - name=message.author, icon_url=avatar_url - ) + embedMessage.set_author(name=message.author, icon_url=avatar_url) # if message has attachments add them if message.attachments: for i in message.attachments: diff --git a/robocop_ng/cogs/role_persistence.py b/robocop_ng/cogs/role_persistence.py index 29d1ca0..eb889ba 100644 --- a/robocop_ng/cogs/role_persistence.py +++ b/robocop_ng/cogs/role_persistence.py @@ -12,9 +12,13 @@ class RolePersistence(Cog): async def on_raw_member_remove(self, payload: RawMemberRemoveEvent): save_roles = [] for role in payload.user.roles: - if role.is_assignable() and \ - not role.is_default() and not role.is_premium_subscriber() and \ - not role.is_bot_managed() and not role.is_integration(): + if ( + role.is_assignable() + and not role.is_default() + and not role.is_premium_subscriber() + and not role.is_bot_managed() + and not role.is_integration() + ): save_roles.append(role.id) if len(save_roles) > 0: @@ -24,9 +28,15 @@ class RolePersistence(Cog): async def on_member_join(self, member: Member): user_roles = get_user_roles(member.id) if len(user_roles) > 0: - user_roles = [member.guild.get_role(int(role)) for role in user_roles - if member.guild.get_role(int(role)) is not None] - await member.add_roles(*user_roles, reason="Restoring old roles from `role_persistence`.") + user_roles = [ + member.guild.get_role(int(role)) + for role in user_roles + if member.guild.get_role(int(role)) is not None + ] + await member.add_roles( + *user_roles, reason="Restoring old roles from `role_persistence`." + ) + async def setup(bot): await bot.add_cog(RolePersistence(bot)) diff --git a/robocop_ng/cogs/ryujinx_reactionroles.py b/robocop_ng/cogs/ryujinx_reactionroles.py index 1de12c2..cc82cf7 100644 --- a/robocop_ng/cogs/ryujinx_reactionroles.py +++ b/robocop_ng/cogs/ryujinx_reactionroles.py @@ -89,7 +89,6 @@ class RyujinxReactionRoles(Cog): emoji = f"<{emoji}>" if type(value) is str: - description.append( f"{emoji} for __{self.emoji_map.get(x).split('(')[1].split(')')[0]}__" ) @@ -126,7 +125,11 @@ class RyujinxReactionRoles(Cog): if self.get_role_from_emoji(emoji_name) is not None: role = self.get_role(emoji_name) - if not user in role.members and not user.bot and type(user) is discord.Member: + if ( + not user in role.members + and not user.bot + and type(user) is discord.Member + ): await user.add_roles(role) else: await self.m.clear_reaction(reaction.emoji) @@ -247,7 +250,6 @@ class RyujinxReactionRoles(Cog): emoji_name = self.get_emoji_full_name(payload.emoji) if self.get_role_from_emoji(emoji_name) is not None: - guild = discord.utils.find( lambda guild: guild.id == payload.guild_id, self.bot.guilds )