diff --git a/cogs/mod.py b/cogs/mod.py index dec013d..a4e3e48 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -55,13 +55,7 @@ class Mod(commands.Cog): @commands.slash_command(name="block") @owner_or_admin() - async def block_user( - self, - ctx: discord.ApplicationContext, - user: discord.Member, - reason: str, - until: str - ): + async def block_user(self, ctx: discord.ApplicationContext, user: discord.Member, reason: str, until: str): """Blocks a user from using the bot.""" await ctx.defer() date = datetime.utcnow() diff --git a/cogs/other.py b/cogs/other.py index 2cfade5..dac4802 100644 --- a/cogs/other.py +++ b/cogs/other.py @@ -439,29 +439,29 @@ class OtherCog(commands.Cog): @commands.slash_command() async def dig( - self, - ctx: discord.ApplicationContext, - domain: str, - _type: discord.Option( - str, - name="type", - default="A", - choices=[ - "A", - "AAAA", - "ANY", - "AXFR", - "CNAME", - "HINFO", - "LOC", - "MX", - "NS", - "PTR", - "SOA", - "SRV", - "TXT", - ] - ) + self, + ctx: discord.ApplicationContext, + domain: str, + _type: discord.Option( + str, + name="type", + default="A", + choices=[ + "A", + "AAAA", + "ANY", + "AXFR", + "CNAME", + "HINFO", + "LOC", + "MX", + "NS", + "PTR", + "SOA", + "SRV", + "TXT", + ], + ), ): """Looks up a domain name""" await ctx.defer() @@ -494,46 +494,28 @@ class OtherCog(commands.Cog): @commands.slash_command() async def traceroute( - self, - ctx: discord.ApplicationContext, - url: str, - port: discord.Option( - int, - description="Port to use", - default=None - ), - ping_type: discord.Option( - str, - name="ping-type", - description="Type of ping to use. See `traceroute --help`", - choices=["icmp", "tcp", "udp", "udplite", "dccp", "default"], - default="default" - ), - use_ip_version: discord.Option( - str, - name="ip-version", - description="IP version to use.", - choices=["ipv4", "ipv6"], - default="ipv4" - ), - max_ttl: discord.Option( - int, - name="ttl", - description="Max number of hops", - default=30 - ) + self, + ctx: discord.ApplicationContext, + url: str, + port: discord.Option(int, description="Port to use", default=None), + ping_type: discord.Option( + str, + name="ping-type", + description="Type of ping to use. See `traceroute --help`", + choices=["icmp", "tcp", "udp", "udplite", "dccp", "default"], + default="default", + ), + use_ip_version: discord.Option( + str, name="ip-version", description="IP version to use.", choices=["ipv4", "ipv6"], default="ipv4" + ), + max_ttl: discord.Option(int, name="ttl", description="Max number of hops", default=30), ): """Performs a traceroute request.""" await ctx.defer() if re.search(r"\s+", url): return await ctx.respond("URL cannot contain spaces.") - args = [ - "sudo", - "-E", - "-n", - "traceroute" - ] + args = ["sudo", "-E", "-n", "traceroute"] flags = { "ping_type": { "icmp": "-I", @@ -542,10 +524,7 @@ class OtherCog(commands.Cog): "udplite": "-UL", "dccp": "-D", }, - "use_ip_version": { - "ipv4": "-4", - "ipv6": "-6" - } + "use_ip_version": {"ipv4": "-4", "ipv6": "-6"}, } if ping_type != "default": @@ -683,7 +662,14 @@ class OtherCog(commands.Cog): try: async with self.lock: screenshot, driver, fetch_time, screenshot_time = await self.screenshot_website( - ctx, url.geturl(), browser, render_timeout, load_timeout, window_height, window_width, capture_whole_page + ctx, + url.geturl(), + browser, + render_timeout, + load_timeout, + window_height, + window_width, + capture_whole_page, ) except TimeoutError: return await ctx.edit(content="Rendering screenshot timed out. Try using a smaller resolution.") diff --git a/cogs/uptime.py b/cogs/uptime.py index 2b5589d..a905d5b 100644 --- a/cogs/uptime.py +++ b/cogs/uptime.py @@ -282,7 +282,6 @@ class UptimeCompetition(commands.Cog): def generate_embed(target, specific_entries: list[UptimeEntry]): targ = target - # targ = self.get_target(target_id=target) embed = discord.Embed( title=f"Uptime stats for {targ['name']}", description=f"Showing uptime stats for the last {look_back:,} days.", @@ -308,10 +307,12 @@ class UptimeCompetition(commands.Cog): name="\u200b", value=f"*Started monitoring {discord.utils.format_dt(first_check, style='R')}, " f"{total_count:,} monitoring events collected*\n" - f"**Online:**\n\t\\* {online_avg:.2f}% of the time\n\t\\* Last online: " + f"**Online:**\n\t\\* {online_avg:.2f}% of the time ({online_count:,} events)\n\t" + f"\\* Last seen online: " f"{discord.utils.format_dt(last_online, 'R') if last_online else 'Never'}\n" f"\n" - f"**Offline:**\n\t\\* {100 - online_avg:.2f}% of the time\n\t\\* Last offline: " + f"**Offline:**\n\t\\* {100 - online_avg:.2f}% of the time ({offline_count:,} events)\n\t" + f"\\* Last seen offline: " f"{discord.utils.format_dt(last_offline, 'R') if last_offline else 'Never'}\n" f"\n" f"**Average Response Time:**\n\t\\* {average_response_time:.2f}ms", @@ -499,18 +500,18 @@ class UptimeCompetition(commands.Cog): await ctx.respond("Monitor added!") @monitors.command(name="dump") - async def show_monitor(self, ctx: discord.ApplicationContext, name: discord.Option(str, description="The name of the monitor.")): - """Shows a monitors data.""" + async def show_monitor( + self, ctx: discord.ApplicationContext, name: discord.Option(str, description="The name of the monitor.") + ): + """Shows a monitor's data.""" await ctx.defer() name: str - targets = self.cached_targets - for target in targets: - if target["name"] == name or target["id"] == name: - return await ctx.respond(f"```json\n{json.dumps(target, indent=4)}```") + target = self.get_target(name) + if target: + return await ctx.respond(f"```json\n{json.dumps(target, indent=4)}```") await ctx.respond("Monitor not found.") - @monitors.command(name="remove") @commands.is_owner() async def remove_monitor( diff --git a/utils/db.py b/utils/db.py index 89b93a7..5192e36 100644 --- a/utils/db.py +++ b/utils/db.py @@ -30,7 +30,7 @@ __all__ = [ "Assignments", "Tutors", "UptimeEntry", - "JimmyBans" + "JimmyBans", ] T = TypeVar("T")