diff --git a/minato_namikaze/cogs/dev/developer.py b/minato_namikaze/cogs/dev/developer.py index cfa4dd3b..e9b2bdd2 100644 --- a/minato_namikaze/cogs/dev/developer.py +++ b/minato_namikaze/cogs/dev/developer.py @@ -158,7 +158,10 @@ async def sharedservers( user: Union[discord.Member, MemberID], ): """Get a list of servers the bot shares with the user.""" - guilds = [f"{guild.name} `{guild.id}` ({guild.member_count} members)" for guild in list(user.mutual_guilds)] + guilds = [ + f"{guild.name} `{guild.id}` ({guild.member_count} members)" + for guild in list(user.mutual_guilds) + ] await self._send_guilds(ctx, guilds, "Shared Servers") @@ -320,7 +323,8 @@ async def sync(self, ctx: Context): [f"**{g[0]}** ```diff\n- {g[1]}```" for g in error_collection], ) return await ctx.send( - f"Attempted to reload all extensions, was able to reload, " f"however the following failed...\n\n{err}", + f"Attempted to reload all extensions, was able to reload, " + f"however the following failed...\n\n{err}", ) await msg.edit(embed=embed) @@ -438,7 +442,8 @@ async def on_message(self, message: discord.Message): ( self.bot.user.mentioned_in(message) and message.mention_everyone is False - and message.content.lower() in (f"<@!{self.bot.application_id}>", f"<@{self.bot.application_id}>") + and message.content.lower() + in (f"<@!{self.bot.application_id}>", f"<@{self.bot.application_id}>") or message.content.lower() in ( f"<@!{self.bot.application_id}> prefix", @@ -458,7 +463,11 @@ async def on_message(self, message: discord.Message): except: pass - if link_res := INVITE_URL_RE.findall(message.content) and not message.author.bot and not message.guild: + if ( + link_res := INVITE_URL_RE.findall(message.content) + and not message.author.bot + and not message.guild + ): msg = "Thank you for showing interest in me. If you want to add me to your server, please ask the server owner to add me to the server. If you are the server owner, please click on the link below to add me to your server.\n\n{link}" if "{link}" in msg: msg = msg.format(link=await self.bot.get_required_perms_invite_link) diff --git a/minato_namikaze/cogs/dev/forward.py b/minato_namikaze/cogs/dev/forward.py index 4a934061..776e5fac 100644 --- a/minato_namikaze/cogs/dev/forward.py +++ b/minato_namikaze/cogs/dev/forward.py @@ -24,7 +24,9 @@ def __init__(self, bot): async def _destination(self, msg: str = None, embed: discord.Embed = None): await self.bot.wait_until_ready() - channel = self.bot.get_channel(ChannelAndMessageId.forward_dm_messages_channel_id.value) + channel = self.bot.get_channel( + ChannelAndMessageId.forward_dm_messages_channel_id.value + ) if channel is None: await self.bot.send_to_owners(msg, embed=embed) else: @@ -34,7 +36,10 @@ async def _destination(self, msg: str = None, embed: discord.Embed = None): def _append_attachements(message: discord.Message, embeds: list): attachments_urls = [] for attachment in message.attachments: - if any(attachment.filename.endswith(imageext) for imageext in ["jpg", "png", "gif"]): + if any( + attachment.filename.endswith(imageext) + for imageext in ["jpg", "png", "gif"] + ): if embeds[0].image: embed = discord.Embed() embed.set_image(url=attachment.url) diff --git a/minato_namikaze/cogs/moderation/moderation.py b/minato_namikaze/cogs/moderation/moderation.py index 64055acb..657feb71 100644 --- a/minato_namikaze/cogs/moderation/moderation.py +++ b/minato_namikaze/cogs/moderation/moderation.py @@ -488,7 +488,9 @@ async def tempban( ) until = f'until {format_dt(duration.dt, "F")}' - heads_up_message = f"You have been banned from {ctx.guild.name} {until}. Reason: {reason}" + heads_up_message = ( + f"You have been banned from {ctx.guild.name} {until}. Reason: {reason}" + ) try: await member.send(heads_up_message) # type: ignore # Guarded by AttributeError @@ -530,7 +532,9 @@ async def on_tempban_timer_complete(self, timer: Timer): else: moderator = f"{moderator} (ID: {mod_id})" - reason = f"Automatic unban from timer made on {timer.created_at} by {moderator}." + reason = ( + f"Automatic unban from timer made on {timer.created_at} by {moderator}." + ) await guild.unban(discord.Object(id=member_id), reason=reason) @commands.command() @@ -660,7 +664,8 @@ async def massban(self, ctx: Context, *, args): # member filters predicates = [ - lambda m: isinstance(m, discord.Member) and can_execute_action(ctx, author, m), # Only if applicable + lambda m: isinstance(m, discord.Member) + and can_execute_action(ctx, author, m), # Only if applicable lambda m: not m.bot, # No bots lambda m: m.discriminator != "0000", # No deleted users ] @@ -704,7 +709,11 @@ def joined(member, *, offset=now - datetime.timedelta(minutes=args.joined)): _joined_after_member = await converter.convert(ctx, str(args.joined_after)) def joined_after(member, *, _other=_joined_after_member): - return member.joined_at and _other.joined_at and member.joined_at > _other.joined_at + return ( + member.joined_at + and _other.joined_at + and member.joined_at > _other.joined_at + ) predicates.append(joined_after) if args.joined_before: @@ -714,7 +723,11 @@ def joined_after(member, *, _other=_joined_after_member): ) def joined_before(member, *, _other=_joined_before_member): - return member.joined_at and _other.joined_at and member.joined_at < _other.joined_at + return ( + member.joined_at + and _other.joined_at + and member.joined_at < _other.joined_at + ) predicates.append(joined_before) @@ -724,7 +737,10 @@ def joined_before(member, *, _other=_joined_before_member): if args.show: members = sorted(members, key=lambda m: m.joined_at or now) - fmt = "\n".join(f"{m.id}\tJoined: {m.joined_at}\tCreated: {m.created_at}\t{m}" for m in members) + fmt = "\n".join( + f"{m.id}\tJoined: {m.joined_at}\tCreated: {m.created_at}\t{m}" + for m in members + ) content = f"Current Time: {discord.utils.utcnow()}\nTotal members: {len(members)}\n{fmt}" file = discord.File( io.BytesIO(content.encode("utf-8")), @@ -848,7 +864,9 @@ async def newusers(self, ctx: Context, *, count: int | None = 5): if not ctx.guild.chunked: members = await ctx.guild.chunk(cache=True) - members = sorted(ctx.guild.members, key=lambda m: m.joined_at, reverse=True)[:count] + members = sorted(ctx.guild.members, key=lambda m: m.joined_at, reverse=True)[ + :count + ] embed = discord.Embed(title="New Members", colour=discord.Colour.green()) @@ -886,7 +904,9 @@ async def _regular_user_cleanup_strategy(self, ctx: Context, search): prefixes = tuple(self.bot.get_guild_prefixes(ctx.guild)) def check(m): - return (m.author == ctx.me or m.content.startswith(prefixes)) and not (m.mentions or m.role_mentions) + return (m.author == ctx.me or m.content.startswith(prefixes)) and not ( + m.mentions or m.role_mentions + ) deleted = await ctx.channel.purge(limit=search, check=check, before=ctx.message) return Counter(m.author.display_name for m in deleted) @@ -1066,7 +1086,9 @@ async def _bot(self, ctx: Context, prefix=None, search=100): """Removes a bot user's messages and messages with their optional prefix.""" def predicate(m): - return (m.webhook_id is None and m.author.bot) or (prefix and m.content.startswith(prefix)) + return (m.webhook_id is None and m.author.bot) or ( + prefix and m.content.startswith(prefix) + ) await self.do_removal(ctx, search, predicate) diff --git a/minato_namikaze/discordbot.py b/minato_namikaze/discordbot.py index 95bb5153..8ef20faa 100755 --- a/minato_namikaze/discordbot.py +++ b/minato_namikaze/discordbot.py @@ -409,7 +409,9 @@ def get_random_image_from_tag(tag_name: str) -> str | None: return api_model = TenGiphPy.Giphy(token=Tokens.giphy.value) try: - return api_model.random(str(tag_name.lower()))["data"]["images"]["downsized_large"]["url"] + return api_model.random(str(tag_name.lower()))["data"]["images"][ + "downsized_large" + ]["url"] except: return @@ -424,7 +426,9 @@ async def get_random_image_from_tag(tag_name: str) -> str | None: return api_model = TenGiphPy.Giphy(token=Tokens.giphy.value) try: - return (await api_model.arandom(tag=str(tag_name.lower())))["data"]["images"]["downsized_large"]["url"] + return (await api_model.arandom(tag=str(tag_name.lower())))["data"][ + "images" + ]["downsized_large"]["url"] except: return @@ -440,7 +444,9 @@ def tenor(tag_name: str) -> str | None: async def giphy(tag_name: str) -> str | None: api_model = TenGiphPy.Giphy(token=Tokens.giphy.value) try: - return (await api_model.arandom(tag=str(tag_name.lower())))["data"]["images"]["downsized_large"]["url"] + return (await api_model.arandom(tag=str(tag_name.lower())))["data"][ + "images" + ]["downsized_large"]["url"] except: return diff --git a/minato_namikaze/lib/util/utility.py b/minato_namikaze/lib/util/utility.py index 37863187..733a1769 100644 --- a/minato_namikaze/lib/util/utility.py +++ b/minato_namikaze/lib/util/utility.py @@ -186,7 +186,10 @@ def humanize_attachments(attachments: list) -> list: def format_character_name(character_name: str) -> str: - if character_name.split("(")[-1].strip(" ").strip(")").lower() in ChannelAndMessageId.character_side_exclude.name: + if ( + character_name.split("(")[-1].strip(" ").strip(")").lower() + in ChannelAndMessageId.character_side_exclude.name + ): return character_name.split("(")[0].strip(" ").title() return character_name.strip(" ").title() @@ -222,7 +225,11 @@ async def detect_bad_domains(message_content: str) -> list: if len(i.split("//")) != 0: try: parsed_url = urlparse( - (i.lower().strip("/") if i.split("://")[0].lower() in uses_netloc else f'//{i.strip("/")}'), + ( + i.lower().strip("/") + if i.split("://")[0].lower() in uses_netloc + else f'//{i.strip("/")}' + ), ) if parsed_url.hostname in list_of_bad_domains: detected_urls.append(parsed_url.hostname) @@ -244,10 +251,18 @@ def return_all_cogs() -> list[str]: for filename in list(set(os.listdir(cog_dir))): if os.path.isdir(cog_dir / filename): for i in os.listdir(cog_dir / filename): - if i.endswith(".py") and not i.startswith("__init__") and not i.endswith(".pyc"): + if ( + i.endswith(".py") + and not i.startswith("__init__") + and not i.endswith(".pyc") + ): list_to_be_given.append(f'{filename.strip(" ")}.{i[:-3]}') else: - if filename.endswith(".py") and not filename.startswith("__init__") and not filename.endswith(".pyc"): + if ( + filename.endswith(".py") + and not filename.startswith("__init__") + and not filename.endswith(".pyc") + ): list_to_be_given.append(filename[:-3]) return list_to_be_given diff --git a/minato_namikaze/lib/util/vars.py b/minato_namikaze/lib/util/vars.py index 8cc60db5..944a037d 100644 --- a/minato_namikaze/lib/util/vars.py +++ b/minato_namikaze/lib/util/vars.py @@ -155,11 +155,15 @@ class LinksAndVars(enum.Enum): github = "https://github.com/The-4th-Hokage/yondaime-hokage" bad_links = "https://raw.githubusercontent.com/The-4th-Hokage/bad-domains-list/master/bad-domains.txt" - listing = "https://raw.githubusercontent.com/The-4th-Hokage/listing/master/listing.json" + listing = ( + "https://raw.githubusercontent.com/The-4th-Hokage/listing/master/listing.json" + ) character_data = "https://raw.githubusercontent.com/The-4th-Hokage/naruto-card-game-images/master/img_data.json" statuspage_link = "https://minatonamikaze.statuspage.io" - mal_logo = "https://cdn.myanimelist.net/images/event/15th_anniversary/top_page/item7.png" + mal_logo = ( + "https://cdn.myanimelist.net/images/event/15th_anniversary/top_page/item7.png" + ) giveaway_image = "https://i.imgur.com/efLKnlh.png" invite_redirect_uri = "https://minatonamikaze-invites.herokuapp.com/invite"