From 3418c206d9333405768a7909b5febfb8aa2892fe Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Thu, 10 Nov 2022 15:09:57 +0100 Subject: [PATCH] Apply black formatting --- robocop_ng/cogs/err.py | 8 ++-- robocop_ng/cogs/logfilereader.py | 2 +- robocop_ng/cogs/ryujinx_reactionroles.py | 47 ++++++++++++++++-------- robocop_ng/cogs/ryujinx_verification.py | 16 +++++--- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/robocop_ng/cogs/err.py b/robocop_ng/cogs/err.py index f8470db..09f3774 100644 --- a/robocop_ng/cogs/err.py +++ b/robocop_ng/cogs/err.py @@ -66,7 +66,7 @@ class Err(Cog): @commands.command(aliases=["wiiuserr", "uerr", "wuerr", "mochaerr"]) async def wiiuerr(self, ctx, err: str): """Searches for Wii U error codes! - Usage: .wiiuserr/.uerr/.wuerr/.mochaerr """ + Usage: .wiiuserr/.uerr/.wuerr/.mochaerr """ if self.wiiu_re.match(err): # Wii U module = err[2:3] # Is that even true, idk just guessing desc = err[5:8] @@ -94,7 +94,7 @@ class Err(Cog): @commands.command(aliases=["nxerr", "serr"]) async def err(self, ctx, err: str): """Searches for Switch error codes! - Usage: .serr/.nxerr/.err """ + Usage: .serr/.nxerr/.err """ if self.switch_re.match(err) or err.startswith("0x"): # Switch @@ -168,7 +168,7 @@ class Err(Cog): @commands.command(aliases=["e2h"]) async def err2hex(self, ctx, err: str): """Converts Nintendo Switch errors to hex - Usage: .err2hex """ + Usage: .err2hex """ if self.switch_re.match(err): module = int(err[0:4]) - 2000 desc = int(err[5:9]) @@ -182,7 +182,7 @@ class Err(Cog): @commands.command(aliases=["h2e"]) async def hex2err(self, ctx, err: str): """Converts Nintendo Switch errors to hex - Usage: .hex2err """ + Usage: .hex2err """ if err.startswith("0x"): err = err[2:] err = int(err, 16) diff --git a/robocop_ng/cogs/logfilereader.py b/robocop_ng/cogs/logfilereader.py index 59f5d46..1996c5c 100644 --- a/robocop_ng/cogs/logfilereader.py +++ b/robocop_ng/cogs/logfilereader.py @@ -262,7 +262,7 @@ class LogFileReader(Cog): setting_value = [ line.split()[-1] for line in log_file.splitlines() - if re.search(fr"LogValueChange: ({setting_string})\s", line) + if re.search(rf"LogValueChange: ({setting_string})\s", line) ][-1] if setting_value and setting.get(name): setting[name] = setting_value diff --git a/robocop_ng/cogs/ryujinx_reactionroles.py b/robocop_ng/cogs/ryujinx_reactionroles.py index 351ced1..7b9fda4 100644 --- a/robocop_ng/cogs/ryujinx_reactionroles.py +++ b/robocop_ng/cogs/ryujinx_reactionroles.py @@ -8,6 +8,7 @@ from discord.ext import commands from discord.ext.commands import Cog from helpers.checks import check_if_staff + class RyujinxReactionRoles(Cog): def __init__(self, bot): self.bot = bot @@ -26,7 +27,7 @@ class RyujinxReactionRoles(Cog): async def register_reaction_role(self, ctx, target_role_id: int, emoji_name: str): """Register a reaction role, staff only.""" - if emoji_name[0] == '<': + if emoji_name[0] == "<": emoji_name = emoji_name[1:-1] if target_role_id in config.staff_role_ids: @@ -73,18 +74,22 @@ class RyujinxReactionRoles(Cog): async def generate_embed(self): last_descrption = [] - description = ["React to this message with the emojis given below to get your 'Looking for LDN game' roles. \n"] + description = [ + "React to this message with the emojis given below to get your 'Looking for LDN game' roles. \n" + ] for x in self.emoji_map: value = self.emoji_map[x] emoji = x - if len(emoji.split(':')) == 3: + if len(emoji.split(":")) == 3: emoji = f"<{emoji}>" if type(value) is str: - description.append(f"{emoji} for __{self.emoji_map.get(x).split('(')[1].split(')')[0]}__") + description.append( + f"{emoji} for __{self.emoji_map.get(x).split('(')[1].split(')')[0]}__" + ) else: role_name = value["role"] line_fmt = value["fmt"] @@ -94,7 +99,9 @@ class RyujinxReactionRoles(Cog): description.append(line_fmt.format(emoji, role_name)) embed = discord.Embed( - title="**Select your roles**", description='\n'.join(description) + '\n' + '\n'.join(last_descrption), color=420420 + title="**Select your roles**", + description="\n".join(description) + "\n" + "\n".join(last_descrption), + color=420420, ) embed.set_footer( text="To remove a role, simply remove the corresponding reaction." @@ -106,7 +113,7 @@ class RyujinxReactionRoles(Cog): for reaction in self.m.reactions: for user in await reaction.users().flatten(): emoji_name = str(reaction.emoji) - if emoji_name[0] == '<': + if emoji_name[0] == "<": emoji_name = emoji_name[1:-1] if self.get_role_from_emoji(emoji_name) is not None: @@ -120,7 +127,7 @@ class RyujinxReactionRoles(Cog): for emoji in self.emoji_map: for reaction in self.m.reactions: emoji_name = str(reaction.emoji) - if emoji_name[0] == '<': + if emoji_name[0] == "<": emoji_name = emoji_name[1:-1] role = self.get_role(emoji_name) @@ -141,14 +148,20 @@ class RyujinxReactionRoles(Cog): with open(self.file, "w") as f: json.dump(value, f) - async def reload_reaction_message(self, should_handle_offline = True): - self.emoji_map = collections.OrderedDict(sorted(self.reaction_config["reaction_roles_emoji_map"].items(), key=lambda x: str(x[1]))) - + async def reload_reaction_message(self, should_handle_offline=True): + self.emoji_map = collections.OrderedDict( + sorted( + self.reaction_config["reaction_roles_emoji_map"].items(), + key=lambda x: str(x[1]), + ) + ) guild = self.bot.guilds[0] # The ryu guild in which the bot is. channel = guild.get_channel(self.channel_id) - m = discord.utils.get(await channel.history().flatten(), id=self.reaction_config["id"]) + m = discord.utils.get( + await channel.history().flatten(), id=self.reaction_config["id"] + ) if m is None: self.reaction_config["id"] = None @@ -165,7 +178,9 @@ class RyujinxReactionRoles(Cog): await self.handle_offline_reaction_remove() else: - self.m = discord.utils.get(await channel.history().flatten(), id=self.reaction_config["id"]) + self.m = discord.utils.get( + await channel.history().flatten(), id=self.reaction_config["id"] + ) self.msg_id = self.m.id await self.m.edit(embed=await self.generate_embed()) @@ -195,11 +210,11 @@ class RyujinxReactionRoles(Cog): target_role = self.get_role(emoji_name) if target_role is not None: - await payload.member.add_roles( - target_role - ) + await payload.member.add_roles(target_role) else: - self.bot.log.error(f"Role {self.emoji_map[emoji_name]} not found.") + self.bot.log.error( + f"Role {self.emoji_map[emoji_name]} not found." + ) await self.m.clear_reaction(payload.emoji) else: await self.m.clear_reaction(payload.emoji) diff --git a/robocop_ng/cogs/ryujinx_verification.py b/robocop_ng/cogs/ryujinx_verification.py index 14ed6e4..dbfd751 100644 --- a/robocop_ng/cogs/ryujinx_verification.py +++ b/robocop_ng/cogs/ryujinx_verification.py @@ -18,15 +18,17 @@ class RyujinxVerification(Cog): async def on_member_join(self, member): await self.bot.wait_until_ready() - if (member.guild.id not in config.guild_whitelist): + if member.guild.id not in config.guild_whitelist: return join_channel = self.bot.get_channel(config.welcome_channel) if join_channel is not None: await join_channel.send( - 'Hello {0.mention}! Welcome to Ryujinx! Please read the <#411271165429022730>, and then type the verifying command here to gain access to the rest of the channels.\n\nIf you need help with basic common questions, visit the <#585288848704143371> channel after joining.\n\nIf you need help with Animal Crossing visit the <#692104087889641472> channel for common issues and solutions. If you need help that is not Animal Crossing related, please visit the <#410208610455519243> channel after verifying.'.format( - member)) + "Hello {0.mention}! Welcome to Ryujinx! Please read the <#411271165429022730>, and then type the verifying command here to gain access to the rest of the channels.\n\nIf you need help with basic common questions, visit the <#585288848704143371> channel after joining.\n\nIf you need help with Animal Crossing visit the <#692104087889641472> channel for common issues and solutions. If you need help that is not Animal Crossing related, please visit the <#410208610455519243> channel after verifying.".format( + member + ) + ) async def process_message(self, message): """Process the verification process""" @@ -67,7 +69,7 @@ class RyujinxVerification(Cog): async def on_member_join(self, member): await self.bot.wait_until_ready() - if (member.guild.id not in config.guild_whitelist): + if member.guild.id not in config.guild_whitelist: return join_channel = self.bot.get_channel(config.welcome_channel) @@ -80,8 +82,10 @@ class RyujinxVerification(Cog): async def reset(self, ctx, limit: int = 100, force: bool = False): """Wipes messages and pastes the welcome message again. Staff only.""" if ctx.message.channel.id != config.welcome_channel and not force: - await ctx.send(f"This command is limited to" - f" <#{config.welcome_channel}>, unless forced.") + await ctx.send( + f"This command is limited to" + f" <#{config.welcome_channel}>, unless forced." + ) return await self.do_reset(ctx.channel, ctx.author.mention, limit)