From f831f544b605f5b44ef16152739df89c04501889 Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Thu, 25 Dec 2025 15:32:21 +0000 Subject: [PATCH 1/7] bump pycord --- uv.lock | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/uv.lock b/uv.lock index b628fc43..89145796 100644 --- a/uv.lock +++ b/uv.lock @@ -500,21 +500,21 @@ wheels = [ [[package]] name = "librt" -version = "0.7.4" +version = "0.7.5" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/93/e4/b59bdf1197fdf9888452ea4d2048cdad61aef85eb83e99dc52551d7fdc04/librt-0.7.4.tar.gz", hash = "sha256:3871af56c59864d5fd21d1ac001eb2fb3b140d52ba0454720f2e4a19812404ba", size = 145862, upload-time = "2025-12-15T16:52:43.862Z" } +sdist = { url = "https://files.pythonhosted.org/packages/b5/8a/071f6628363d83e803d4783e0cd24fb9c5b798164300fcfaaa47c30659c0/librt-0.7.5.tar.gz", hash = "sha256:de4221a1181fa9c8c4b5f35506ed6f298948f44003d84d2a8b9885d7e01e6cfa", size = 145868, upload-time = "2025-12-25T03:53:16.039Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/fe/4d/46a53ccfbb39fd0b493fd4496eb76f3ebc15bb3e45d8c2e695a27587edf5/librt-0.7.4-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:d44a1b1ba44cbd2fc3cb77992bef6d6fdb1028849824e1dd5e4d746e1f7f7f0b", size = 55745, upload-time = "2025-12-15T16:51:46.636Z" }, - { url = "https://files.pythonhosted.org/packages/7f/2b/3ac7f5212b1828bf4f979cf87f547db948d3e28421d7a430d4db23346ce4/librt-0.7.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:c9cab4b3de1f55e6c30a84c8cee20e4d3b2476f4d547256694a1b0163da4fe32", size = 57166, upload-time = "2025-12-15T16:51:48.219Z" }, - { url = "https://files.pythonhosted.org/packages/e8/99/6523509097cbe25f363795f0c0d1c6a3746e30c2994e25b5aefdab119b21/librt-0.7.4-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:2857c875f1edd1feef3c371fbf830a61b632fb4d1e57160bb1e6a3206e6abe67", size = 165833, upload-time = "2025-12-15T16:51:49.443Z" }, - { url = "https://files.pythonhosted.org/packages/fe/35/323611e59f8fe032649b4fb7e77f746f96eb7588fcbb31af26bae9630571/librt-0.7.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b370a77be0a16e1ad0270822c12c21462dc40496e891d3b0caf1617c8cc57e20", size = 174818, upload-time = "2025-12-15T16:51:51.015Z" }, - { url = "https://files.pythonhosted.org/packages/41/e6/40fb2bb21616c6e06b6a64022802228066e9a31618f493e03f6b9661548a/librt-0.7.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d05acd46b9a52087bfc50c59dfdf96a2c480a601e8898a44821c7fd676598f74", size = 189607, upload-time = "2025-12-15T16:51:52.671Z" }, - { url = "https://files.pythonhosted.org/packages/32/48/1b47c7d5d28b775941e739ed2bfe564b091c49201b9503514d69e4ed96d7/librt-0.7.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:70969229cb23d9c1a80e14225838d56e464dc71fa34c8342c954fc50e7516dee", size = 184585, upload-time = "2025-12-15T16:51:54.027Z" }, - { url = "https://files.pythonhosted.org/packages/75/a6/ee135dfb5d3b54d5d9001dbe483806229c6beac3ee2ba1092582b7efeb1b/librt-0.7.4-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:4450c354b89dbb266730893862dbff06006c9ed5b06b6016d529b2bf644fc681", size = 178249, upload-time = "2025-12-15T16:51:55.248Z" }, - { url = "https://files.pythonhosted.org/packages/04/87/d5b84ec997338be26af982bcd6679be0c1db9a32faadab1cf4bb24f9e992/librt-0.7.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:adefe0d48ad35b90b6f361f6ff5a1bd95af80c17d18619c093c60a20e7a5b60c", size = 199851, upload-time = "2025-12-15T16:51:56.933Z" }, - { url = "https://files.pythonhosted.org/packages/86/63/ba1333bf48306fe398e3392a7427ce527f81b0b79d0d91618c4610ce9d15/librt-0.7.4-cp313-cp313-win32.whl", hash = "sha256:21ea710e96c1e050635700695095962a22ea420d4b3755a25e4909f2172b4ff2", size = 43249, upload-time = "2025-12-15T16:51:58.498Z" }, - { url = "https://files.pythonhosted.org/packages/f9/8a/de2c6df06cdfa9308c080e6b060fe192790b6a48a47320b215e860f0e98c/librt-0.7.4-cp313-cp313-win_amd64.whl", hash = "sha256:772e18696cf5a64afee908662fbcb1f907460ddc851336ee3a848ef7684c8e1e", size = 49417, upload-time = "2025-12-15T16:51:59.618Z" }, - { url = "https://files.pythonhosted.org/packages/31/66/8ee0949efc389691381ed686185e43536c20e7ad880c122dd1f31e65c658/librt-0.7.4-cp313-cp313-win_arm64.whl", hash = "sha256:52e34c6af84e12921748c8354aa6acf1912ca98ba60cdaa6920e34793f1a0788", size = 42824, upload-time = "2025-12-15T16:52:00.784Z" }, + { url = "https://files.pythonhosted.org/packages/9f/9a/8f61e16de0ff76590af893cfb5b1aa5fa8b13e5e54433d0809c7033f59ed/librt-0.7.5-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:b1795c4b2789b458fa290059062c2f5a297ddb28c31e704d27e161386469691a", size = 55750, upload-time = "2025-12-25T03:52:26.975Z" }, + { url = "https://files.pythonhosted.org/packages/05/7c/a8a883804851a066f301e0bad22b462260b965d5c9e7fe3c5de04e6f91f8/librt-0.7.5-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2fcbf2e135c11f721193aa5f42ba112bb1046afafbffd407cbc81d8d735c74d0", size = 57170, upload-time = "2025-12-25T03:52:27.948Z" }, + { url = "https://files.pythonhosted.org/packages/d6/5d/b3b47facf5945be294cf8a835b03589f70ee0e791522f99ec6782ed738b3/librt-0.7.5-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:c039bbf79a9a2498404d1ae7e29a6c175e63678d7a54013a97397c40aee026c5", size = 165834, upload-time = "2025-12-25T03:52:29.09Z" }, + { url = "https://files.pythonhosted.org/packages/b4/b6/b26910cd0a4e43e5d02aacaaea0db0d2a52e87660dca08293067ee05601a/librt-0.7.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3919c9407faeeee35430ae135e3a78acd4ecaaaa73767529e2c15ca1d73ba325", size = 174820, upload-time = "2025-12-25T03:52:30.463Z" }, + { url = "https://files.pythonhosted.org/packages/a5/a3/81feddd345d4c869b7a693135a462ae275f964fcbbe793d01ea56a84c2ee/librt-0.7.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:26b46620e1e0e45af510d9848ea0915e7040605dd2ae94ebefb6c962cbb6f7ec", size = 189609, upload-time = "2025-12-25T03:52:31.492Z" }, + { url = "https://files.pythonhosted.org/packages/ce/a9/31310796ef4157d1d37648bf4a3b84555319f14cee3e9bad7bdd7bfd9a35/librt-0.7.5-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:9bbb8facc5375476d392990dd6a71f97e4cb42e2ac66f32e860f6e47299d5e89", size = 184589, upload-time = "2025-12-25T03:52:32.59Z" }, + { url = "https://files.pythonhosted.org/packages/32/22/da3900544cb0ac6ab7a2857850158a0a093b86f92b264aa6c4a4f2355ff3/librt-0.7.5-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:e9e9c988b5ffde7be02180f864cbd17c0b0c1231c235748912ab2afa05789c25", size = 178251, upload-time = "2025-12-25T03:52:33.745Z" }, + { url = "https://files.pythonhosted.org/packages/db/77/78e02609846e78b9b8c8e361753b3dbac9a07e6d5b567fe518de9e074ab0/librt-0.7.5-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:edf6b465306215b19dbe6c3fb63cf374a8f3e1ad77f3b4c16544b83033bbb67b", size = 199852, upload-time = "2025-12-25T03:52:34.826Z" }, + { url = "https://files.pythonhosted.org/packages/2a/25/05706f6b346429c951582f1b3561f4d5e1418d0d7ba1a0c181237cd77b3b/librt-0.7.5-cp313-cp313-win32.whl", hash = "sha256:060bde69c3604f694bd8ae21a780fe8be46bb3dbb863642e8dfc75c931ca8eee", size = 43250, upload-time = "2025-12-25T03:52:35.905Z" }, + { url = "https://files.pythonhosted.org/packages/d9/59/c38677278ac0b9ae1afc611382ef6c9ea87f52ad257bd3d8d65f0eacdc6a/librt-0.7.5-cp313-cp313-win_amd64.whl", hash = "sha256:a82d5a0ee43aeae2116d7292c77cc8038f4841830ade8aa922e098933b468b9e", size = 49421, upload-time = "2025-12-25T03:52:36.895Z" }, + { url = "https://files.pythonhosted.org/packages/c0/47/1d71113df4a81de5fdfbd3d7244e05d3d67e89f25455c3380ca50b92741e/librt-0.7.5-cp313-cp313-win_arm64.whl", hash = "sha256:3c98a8d0ac9e2a7cb8ff8c53e5d6e8d82bfb2839abf144fdeaaa832f2a12aa45", size = 42827, upload-time = "2025-12-25T03:52:37.856Z" }, ] [[package]] @@ -811,14 +811,15 @@ wheels = [ [[package]] name = "py-cord" -version = "2.6.1" +version = "2.7.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "aiohttp" }, + { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/27/c7/c539d69d5cfa1ea5891d596212f73d619e40c7fc9f02ae906f4147993b94/py_cord-2.6.1.tar.gz", hash = "sha256:36064f225f2c7bbddfe542d5ed581f2a5744f618e039093cf7cd2659a58bc79b", size = 965087, upload-time = "2024-09-15T19:36:39.245Z" } +sdist = { url = "https://files.pythonhosted.org/packages/7e/13/faca034d886cf7ad504d44d797ed6823dbfbe05f3093ae9cd60bd08b93af/py_cord-2.7.0.tar.gz", hash = "sha256:6f947e6b08ae2884777a3fcb1150d7c0df14c4461e8015ed3d2f29c081e79dfd", size = 1128349, upload-time = "2025-12-24T16:00:02.935Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/e7/90/2690ded84e34b15ca2619932a358c1b7dc6d28fe845dfbd01929fc33c9da/py_cord-2.6.1-py3-none-any.whl", hash = "sha256:e3d3b528c5e37b0e0825f5b884cbb9267860976c1e4878e28b55da8fd3af834b", size = 1089154, upload-time = "2024-09-15T19:36:35.34Z" }, + { url = "https://files.pythonhosted.org/packages/e7/d8/a4094151a7f942c2606c23e5c9cc5fa5f4aba2405e678f23c360f58c8f91/py_cord-2.7.0-py3-none-any.whl", hash = "sha256:7f5badc55f6cd80bac0e65e77a10a3aaac17bc7932c2088035dd925900a4c29e", size = 1204142, upload-time = "2025-12-24T16:00:01.224Z" }, ] [[package]] @@ -874,11 +875,11 @@ wheels = [ [[package]] name = "pyparsing" -version = "3.2.5" +version = "3.3.1" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/f2/a5/181488fc2b9d093e3972d2a472855aae8a03f000592dbfce716a512b3359/pyparsing-3.2.5.tar.gz", hash = "sha256:2df8d5b7b2802ef88e8d016a2eb9c7aeaa923529cd251ed0fe4608275d4105b6", size = 1099274, upload-time = "2025-09-21T04:11:06.277Z" } +sdist = { url = "https://files.pythonhosted.org/packages/33/c1/1d9de9aeaa1b89b0186e5fe23294ff6517fce1bc69149185577cd31016b2/pyparsing-3.3.1.tar.gz", hash = "sha256:47fad0f17ac1e2cad3de3b458570fbc9b03560aa029ed5e16ee5554da9a2251c", size = 1550512, upload-time = "2025-12-23T03:14:04.391Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/10/5e/1aa9a93198c6b64513c9d7752de7422c06402de6600a8767da1524f9570b/pyparsing-3.2.5-py3-none-any.whl", hash = "sha256:e38a4f02064cf41fe6593d328d0512495ad1f3d8a91c4f73fc401b3079a59a5e", size = 113890, upload-time = "2025-09-21T04:11:04.117Z" }, + { url = "https://files.pythonhosted.org/packages/8b/40/2614036cdd416452f5bf98ec037f38a1afb17f327cb8e6b652d4729e0af8/pyparsing-3.3.1-py3-none-any.whl", hash = "sha256:023b5e7e5520ad96642e2c6db4cb683d3970bd640cdf7115049a6e9c3682df82", size = 121793, upload-time = "2025-12-23T03:14:02.103Z" }, ] [[package]] From 0a466044eccbdd3e5880543834e4c5b22d36b7d1 Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Thu, 25 Dec 2025 17:10:47 +0000 Subject: [PATCH 2/7] Fix mypy and ruff errors --- cogs/command_error.py | 14 +-- cogs/induct.py | 4 +- cogs/kill.py | 4 +- cogs/make_applicant.py | 4 +- cogs/remind_me.py | 7 ++ cogs/send_introduction_reminders.py | 8 +- cogs/stats/__init__.py | 131 +++++++++++++++++++++++----- cogs/strike.py | 39 ++++++--- utils/tex_bot_base_cog.py | 14 +-- 9 files changed, 174 insertions(+), 51 deletions(-) diff --git a/cogs/command_error.py b/cogs/command_error.py index fcac8ee1..b7e11de7 100644 --- a/cogs/command_error.py +++ b/cogs/command_error.py @@ -73,12 +73,16 @@ async def on_application_command_error( error.original, GuildDoesNotExistError ): command_name: str = ( - ctx.command.callback.__name__ - if ( - hasattr(ctx.command, "callback") - and not ctx.command.callback.__name__.startswith("_") + ( + ctx.command.callback.__name__ + if ( + hasattr(ctx.command, "callback") + and not ctx.command.callback.__name__.startswith("_") + ) + else ctx.command.qualified_name ) - else ctx.command.qualified_name + if ctx.command + else "UnknownCommand" ) logger.critical( " ".join( diff --git a/cogs/induct.py b/cogs/induct.py index dd52a938..3384f0d1 100644 --- a/cogs/induct.py +++ b/cogs/induct.py @@ -240,7 +240,9 @@ async def _perform_induction( applicant_role, reason=INDUCT_AUDIT_MESSAGE ) - tex_emoji: discord.Emoji | None = self.bot.get_emoji(743218410409820213) + tex_emoji: discord.AppEmoji | discord.GuildEmoji | None = self.bot.get_emoji( + 743218410409820213 + ) if not tex_emoji: tex_emoji = discord.utils.get(main_guild.emojis, name="TeX") diff --git a/cogs/kill.py b/cogs/kill.py index 2ca4e3b3..ff242c78 100644 --- a/cogs/kill.py +++ b/cogs/kill.py @@ -28,7 +28,7 @@ class ConfirmKillView(View): @discord.ui.button( label="SHUTDOWN", style=discord.ButtonStyle.red, custom_id="shutdown_confirm" ) - async def confirm_shutdown_button_callback( # type: ignore[misc] + async def confirm_shutdown_button_callback( self, _: discord.Button, interaction: discord.Interaction ) -> None: """When the shutdown button is pressed, delete the message.""" @@ -37,7 +37,7 @@ async def confirm_shutdown_button_callback( # type: ignore[misc] @discord.ui.button( label="CANCEL", style=discord.ButtonStyle.grey, custom_id="shutdown_cancel" ) - async def cancel_shutdown_button_callback( # type: ignore[misc] + async def cancel_shutdown_button_callback( self, _: discord.Button, interaction: discord.Interaction ) -> None: """When the cancel button is pressed, delete the message.""" diff --git a/cogs/make_applicant.py b/cogs/make_applicant.py index 619d7756..4c63115c 100644 --- a/cogs/make_applicant.py +++ b/cogs/make_applicant.py @@ -63,7 +63,9 @@ async def _perform_make_applicant( await applicant_member.add_roles(applicant_role, reason=AUDIT_MESSAGE) logger.debug("Applicant role given to user %s", applicant_member) - tex_emoji: discord.Emoji | None = self.bot.get_emoji(743218410409820213) + tex_emoji: discord.AppEmoji | discord.GuildEmoji | None = self.bot.get_emoji( + 743218410409820213 + ) if not tex_emoji: tex_emoji = discord.utils.get(main_guild.emojis, name="TeX") diff --git a/cogs/remind_me.py b/cogs/remind_me.py index bd3457a2..f0bfe0e3 100644 --- a/cogs/remind_me.py +++ b/cogs/remind_me.py @@ -210,6 +210,13 @@ async def remind_me( The "remind_me" command responds with the given message after the specified time. """ + if not ctx.channel: + await self.command_send_error( + ctx, + message="Interaction channel was None while trying to set a reminder.", + ) + return + parsed_time: tuple[time.struct_time, int] = parsedatetime.Calendar().parseDT( delay, tzinfo=timezone.get_current_timezone() ) diff --git a/cogs/send_introduction_reminders.py b/cogs/send_introduction_reminders.py index 67480680..6c7facca 100644 --- a/cogs/send_introduction_reminders.py +++ b/cogs/send_introduction_reminders.py @@ -6,9 +6,7 @@ import discord import emoji -from discord import ui from discord.ext import tasks -from discord.ui import View from django.core.exceptions import ValidationError import utils @@ -185,7 +183,7 @@ async def send_introduction_reminders(self) -> None: )[0], ) - class OptOutIntroductionRemindersView(View): + class OptOutIntroductionRemindersView(discord.ui.View): """ A discord.View containing a button to opt-in/out of introduction reminders. @@ -227,13 +225,13 @@ async def send_error( logging_message=logging_message, ) - @ui.button( + @discord.ui.button( label="Opt-out of introduction reminders", custom_id="opt_out_introduction_reminders_button", style=discord.ButtonStyle.red, emoji=discord.PartialEmoji.from_str(emoji.emojize(":no_good:", language="alias")), ) - async def opt_out_introduction_reminders_button_callback( # type: ignore[misc] + async def opt_out_introduction_reminders_button_callback( self, button: discord.Button, interaction: discord.Interaction ) -> None: """ diff --git a/cogs/stats/__init__.py b/cogs/stats/__init__.py index ac798f43..fd78cf43 100644 --- a/cogs/stats/__init__.py +++ b/cogs/stats/__init__.py @@ -1,7 +1,6 @@ """Contains cog classes for any stats interactions.""" import math -import re from typing import TYPE_CHECKING import discord @@ -83,32 +82,64 @@ async def channel_stats( The "channel_stats" command sends a graph of the stats about messages sent in the given channel. """ - # NOTE: Shortcut accessors are placed at the top of the function so that the exceptions they raise are displayed before any further errors may be sent - main_guild: discord.Guild = self.bot.main_guild + if not ctx.channel or not isinstance( + ctx.channel, (discord.TextChannel, discord.DMChannel) + ): + await self.command_send_error( + ctx, + message="Channel statistics cannot be sent in this channel.", + ) + return - channel_id: int = ctx.channel_id + stats_channel: discord.TextChannel | None - if str_channel_id: - if not re.fullmatch(r"\A\d{17,20}\Z", str_channel_id): + if not str_channel_id: + if not isinstance(ctx.channel, discord.TextChannel): await self.command_send_error( - ctx, message=f"{str_channel_id!r} is not a valid channel ID." + ctx, + message=( + "User did not provide a channel ID and the interaction channel " + "is not a text channel." + ), ) return + stats_channel = ctx.channel - channel_id = int(str_channel_id) + if not stats_channel: + try: + channel_id: int = int(str_channel_id) + except ValueError: + await self.command_send_error( + ctx, + message="The provided channel ID was not a valid integer.", + ) + return - channel: discord.TextChannel | None = discord.utils.get( - main_guild.text_channels, id=channel_id - ) - if not channel: - await self.command_send_error( - ctx, message=f"Text channel with ID {str(channel_id)!r} does not exist." - ) - return + result_channel = ctx.bot.get_channel(channel_id) + if not result_channel: + await self.command_send_error( + ctx, + message="The provided channel ID was not valid or could not be found.", + ) + return + + if not isinstance(result_channel, discord.TextChannel): + await self.command_send_error( + ctx, + message=( + "The provided channel ID relates to a channel type " + "that is not supported." + ), + ) + return + + stats_channel = result_channel await ctx.defer(ephemeral=True) - message_counts: Mapping[str, int] = await get_channel_message_counts(channel=channel) + message_counts: Mapping[str, int] = await get_channel_message_counts( + channel=stats_channel + ) if math.ceil(max(message_counts.values()) / 15) < 1: await self.command_send_error( @@ -128,11 +159,11 @@ async def channel_stats( amount_of_time_formatter(settings["STATISTICS_DAYS"].days, "day") })""" ), - title=f"Most Active Roles in #{channel.name}", - filename=f"{channel.name}_channel_stats.png", + title=f"Most Active Roles in #{stats_channel.name}", + filename=f"{stats_channel.name}_channel_stats.png", description=( "Bar chart of the number of messages " - f"sent by different roles in {channel.mention}." + f"sent by different roles in {stats_channel.mention}." ), extra_text=( "Messages sent by members with multiple roles are counted once " @@ -157,6 +188,26 @@ async def server_stats(self, ctx: "TeXBotApplicationContext") -> None: main_guild: discord.Guild = self.bot.main_guild guest_role: discord.Role = await self.bot.guest_role + if not ctx.channel: + await self.command_send_error( + ctx, + message=( + "Interaction channel was None while attempting to send left member stats." + ), + ) + return + + if isinstance( + ctx.channel, (discord.VoiceChannel, discord.ForumChannel, discord.CategoryChannel) + ): + await self.command_send_error( + ctx, + message=( + "Left member stats cannot be sent in a voice, forum, or category channel." + ), + ) + return + await ctx.defer(ephemeral=True) message_counts: Mapping[str, Mapping[str, int]] = await get_server_message_counts( @@ -248,6 +299,26 @@ async def user_stats(self, ctx: "TeXBotApplicationContext") -> None: ) return + if not ctx.channel: + await self.command_send_error( + ctx, + message=( + "Interaction channel was None while attempting to send left member stats." + ), + ) + return + + if isinstance( + ctx.channel, (discord.VoiceChannel, discord.ForumChannel, discord.CategoryChannel) + ): + await self.command_send_error( + ctx, + message=( + "Left member stats cannot be sent in a voice, forum, or category channel." + ), + ) + return + await ctx.defer(ephemeral=True) message_counts: dict[str, int] = {"Total": 0} @@ -314,6 +385,26 @@ async def left_member_stats(self, ctx: "TeXBotApplicationContext") -> None: # NOTE: Shortcut accessors are placed at the top of the function so that the exceptions they raise are displayed before any further errors may be sent main_guild: discord.Guild = self.bot.main_guild + if not ctx.channel: + await self.command_send_error( + ctx, + message=( + "Interaction channel was None while attempting to send left member stats." + ), + ) + return + + if isinstance( + ctx.channel, (discord.VoiceChannel, discord.ForumChannel, discord.CategoryChannel) + ): + await self.command_send_error( + ctx, + message=( + "Left member stats cannot be sent in a voice, forum, or category channel." + ), + ) + return + await ctx.defer(ephemeral=True) left_member_counts: dict[str, int] = { diff --git a/cogs/strike.py b/cogs/strike.py index 70bfcbe8..92367517 100644 --- a/cogs/strike.py +++ b/cogs/strike.py @@ -94,7 +94,7 @@ class ConfirmStrikeMemberView(View): @discord.ui.button( label="Yes", style=discord.ButtonStyle.red, custom_id="yes_strike_member" ) - async def yes_strike_member_button_callback( # type: ignore[misc] + async def yes_strike_member_button_callback( self, _: discord.Button, interaction: discord.Interaction ) -> None: """ @@ -113,7 +113,7 @@ async def yes_strike_member_button_callback( # type: ignore[misc] @discord.ui.button( label="No", style=discord.ButtonStyle.grey, custom_id="no_strike_member" ) - async def no_strike_member_button_callback( # type: ignore[misc] + async def no_strike_member_button_callback( self, _: discord.Button, interaction: discord.Interaction ) -> None: """ @@ -136,7 +136,7 @@ class ConfirmManualModerationView(View): @discord.ui.button( label="Yes", style=discord.ButtonStyle.red, custom_id="yes_manual_moderation_action" ) - async def yes_manual_moderation_action_button_callback( # type: ignore[misc] + async def yes_manual_moderation_action_button_callback( self, _: discord.Button, interaction: discord.Interaction ) -> None: """ @@ -156,7 +156,7 @@ async def yes_manual_moderation_action_button_callback( # type: ignore[misc] @discord.ui.button( label="No", style=discord.ButtonStyle.grey, custom_id="no_manual_moderation_action" ) - async def no_manual_moderation_action_button_callback( # type: ignore[misc] + async def no_manual_moderation_action_button_callback( self, _: discord.Button, interaction: discord.Interaction ) -> None: """ @@ -180,7 +180,7 @@ class ConfirmStrikesOutOfSyncWithBanView(View): @discord.ui.button( label="Yes", style=discord.ButtonStyle.red, custom_id="yes_out_of_sync_ban_member" ) - async def yes_out_of_sync_ban_member_button_callback( # type: ignore[misc] + async def yes_out_of_sync_ban_member_button_callback( self, _: discord.Button, interaction: discord.Interaction ) -> None: """ @@ -200,7 +200,7 @@ async def yes_out_of_sync_ban_member_button_callback( # type: ignore[misc] @discord.ui.button( label="No", style=discord.ButtonStyle.grey, custom_id="no_out_of_sync_ban_member" ) - async def no_out_of_sync_ban_member_button_callback( # type: ignore[misc] + async def no_out_of_sync_ban_member_button_callback( self, _: discord.Button, interaction: discord.Interaction ) -> None: """ @@ -264,7 +264,7 @@ async def _send_strike_user_message( async def _confirm_perform_moderation_action( self, message_sender_component: "MessageSavingSenderComponent", - interaction_user: discord.User, + interaction_user: discord.User | discord.Member, strike_user: discord.Member, confirm_strike_message: str, actual_strike_amount: int, @@ -315,7 +315,7 @@ async def _confirm_perform_moderation_action( async def _confirm_increase_strike( self, message_sender_component: "MessageSavingSenderComponent", - interaction_user: discord.User, + interaction_user: discord.User | discord.Member, strike_user: discord.User | discord.Member, member_strikes: DiscordMemberStrikes, button_callback_channel: discord.TextChannel | discord.DMChannel, @@ -416,6 +416,16 @@ async def _command_perform_strike( ) )[0] + if not (isinstance(ctx.channel, (discord.TextChannel, discord.DMChannel))): + await self.command_send_error( + ctx, + message=( + "Cannot perform strike action in this channel. Channel: " + f"{ctx.channel!r} which has type: {type(ctx.channel).__name__!r}" + ), + ) + return + await self._confirm_increase_strike( message_sender_component=ResponseMessageSender(ctx), interaction_user=ctx.user, @@ -504,7 +514,8 @@ async def _confirm_manual_add_strike( # noqa: PLR0915 async for _audit_log_entry in main_guild.audit_logs( after=discord.utils.utcnow() - datetime.timedelta(minutes=1), action=action ) - if _audit_log_entry.target.id + if _audit_log_entry.target + and _audit_log_entry.target.id == strike_user.id # NOTE: IDs are checked here rather than the objects themselves as the audit log provides an unusual object type in some cases. ) except (StopIteration, StopAsyncIteration): @@ -750,9 +761,13 @@ async def on_member_update(self, before: discord.Member, after: discord.Member) audit_log_entry: discord.AuditLogEntry async for audit_log_entry in main_guild.audit_logs(limit=5): - FOUND_CORRECT_AUDIT_LOG_ENTRY: bool = audit_log_entry.target.id == after.id and ( - audit_log_entry.action - == discord.AuditLogAction.auto_moderation_user_communication_disabled + FOUND_CORRECT_AUDIT_LOG_ENTRY: bool = ( + (audit_log_entry.target is not None) + and (audit_log_entry.target.id == after.id) + and ( + audit_log_entry.action + == discord.AuditLogAction.auto_moderation_user_communication_disabled + ) ) if FOUND_CORRECT_AUDIT_LOG_ENTRY: await self._confirm_manual_add_strike( diff --git a/utils/tex_bot_base_cog.py b/utils/tex_bot_base_cog.py index cec32f81..cc16befe 100644 --- a/utils/tex_bot_base_cog.py +++ b/utils/tex_bot_base_cog.py @@ -82,12 +82,16 @@ async def command_send_error( application command context. """ COMMAND_NAME: Final[str] = ( - ctx.command.callback.__name__ - if ( - hasattr(ctx.command, "callback") - and not ctx.command.callback.__name__.startswith("_") + ( + ctx.command.callback.__name__ + if ( + hasattr(ctx.command, "callback") + and not ctx.command.callback.__name__.startswith("_") + ) + else ctx.command.qualified_name ) - else ctx.command.qualified_name + if ctx.command + else "UnknownCommand" ) await self.send_error( From 4ef4ffc24ce4ba0c1eec451bbba69ca15b5ea7ac Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Thu, 25 Dec 2025 17:20:22 +0000 Subject: [PATCH 3/7] Improve error messages --- cogs/stats/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cogs/stats/__init__.py b/cogs/stats/__init__.py index fd78cf43..8915c810 100644 --- a/cogs/stats/__init__.py +++ b/cogs/stats/__init__.py @@ -91,7 +91,7 @@ async def channel_stats( ) return - stats_channel: discord.TextChannel | None + stats_channel: discord.TextChannel | None = None if not str_channel_id: if not isinstance(ctx.channel, discord.TextChannel): @@ -192,7 +192,7 @@ async def server_stats(self, ctx: "TeXBotApplicationContext") -> None: await self.command_send_error( ctx, message=( - "Interaction channel was None while attempting to send left member stats." + "Interaction channel was None while attempting to send server stats." ), ) return @@ -203,7 +203,7 @@ async def server_stats(self, ctx: "TeXBotApplicationContext") -> None: await self.command_send_error( ctx, message=( - "Left member stats cannot be sent in a voice, forum, or category channel." + "Server stats cannot be sent in a voice, forum, or category channel." ), ) return @@ -303,7 +303,7 @@ async def user_stats(self, ctx: "TeXBotApplicationContext") -> None: await self.command_send_error( ctx, message=( - "Interaction channel was None while attempting to send left member stats." + "Interaction channel was None while attempting to send user stats." ), ) return @@ -314,7 +314,7 @@ async def user_stats(self, ctx: "TeXBotApplicationContext") -> None: await self.command_send_error( ctx, message=( - "Left member stats cannot be sent in a voice, forum, or category channel." + "User stats cannot be sent in a voice, forum, or category channel." ), ) return From b729375af5c293b22512163cf458e48d10b6e27f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 17:22:42 +0000 Subject: [PATCH 4/7] [pre-commit.ci lite] apply automatic fixes --- cogs/stats/__init__.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cogs/stats/__init__.py b/cogs/stats/__init__.py index 8915c810..c79a646c 100644 --- a/cogs/stats/__init__.py +++ b/cogs/stats/__init__.py @@ -302,9 +302,7 @@ async def user_stats(self, ctx: "TeXBotApplicationContext") -> None: if not ctx.channel: await self.command_send_error( ctx, - message=( - "Interaction channel was None while attempting to send user stats." - ), + message=("Interaction channel was None while attempting to send user stats."), ) return @@ -313,9 +311,7 @@ async def user_stats(self, ctx: "TeXBotApplicationContext") -> None: ): await self.command_send_error( ctx, - message=( - "User stats cannot be sent in a voice, forum, or category channel." - ), + message=("User stats cannot be sent in a voice, forum, or category channel."), ) return From abc320c20fb0136db9e2d1f9813ee7871e10abdb Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Fri, 26 Dec 2025 22:55:49 +0000 Subject: [PATCH 5/7] Bump again --- uv.lock | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/uv.lock b/uv.lock index d85de7c6..0aa2b32c 100644 --- a/uv.lock +++ b/uv.lock @@ -702,28 +702,28 @@ wheels = [ [[package]] name = "prek" -version = "0.2.24" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/cd/67/33ff75b530d8f189f18a06b38dc8f684d07ffca045e043293bf043dd963b/prek-0.2.24.tar.gz", hash = "sha256:f7588b9aa0763baf3b2e2bd1b9f103f43e74e494e3e3e12c71270118f56b3f3e", size = 273552, upload-time = "2025-12-23T03:59:10.059Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/27/bc/e67414efd29b81626016a16b7d9f33bb67f4adf47ea8554ae11b7fcb46e3/prek-0.2.24-py3-none-linux_armv6l.whl", hash = "sha256:2b36f04353cf0bbee35b510c83bf2a071682745be0d5265e821934a94869a7f7", size = 4793435, upload-time = "2025-12-23T03:59:19.779Z" }, - { url = "https://files.pythonhosted.org/packages/3f/66/9a724e7b3e3a389e1e0cbacf0f4707ee056c83361925cadef43489b5012d/prek-0.2.24-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:8149aa03eb993ba7c0a7509abccdf30665455db2405eb941c1c4174e3441c6b3", size = 4890722, upload-time = "2025-12-23T03:59:18.299Z" }, - { url = "https://files.pythonhosted.org/packages/2d/cf/ee4c057f08a137ec85cc525f4170c3b930d8edd0a8ead20952c8079199c7/prek-0.2.24-py3-none-macosx_11_0_arm64.whl", hash = "sha256:100bf066669834876f87af11c79bdd4a3c8c1e8abf49aa047bc9c52265f5f544", size = 4615935, upload-time = "2025-12-23T03:59:20.947Z" }, - { url = "https://files.pythonhosted.org/packages/c4/71/a84ae24a82814896220fa3a03f07a62fb2e3f3ed6aa9c3952aaedb008b12/prek-0.2.24-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:656295670b7646936d5d738a708b310900870f47757375214dfaa592786702be", size = 4812259, upload-time = "2025-12-23T03:59:26.671Z" }, - { url = "https://files.pythonhosted.org/packages/55/9a/a009873b954f726f8f43be8d660095c76d47208c6e9397d75f916f52b8fc/prek-0.2.24-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3b79fe57f59fa2649d8a727152af742353de8d537ade75285bedf49b66bf8768", size = 4713078, upload-time = "2025-12-23T03:59:29.51Z" }, - { url = "https://files.pythonhosted.org/packages/37/b3/daf4a1da6f009f4413ca6302b6f6480f824be2447dc74606981c47958ad1/prek-0.2.24-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f02a79c76a84339eecc2d01b1e5f81eb4e8769629e9a62343a8e4089778db956", size = 5034136, upload-time = "2025-12-23T03:59:06.775Z" }, - { url = "https://files.pythonhosted.org/packages/49/17/2b754198c7444f9b8f09c60280e601659afb6a4d6ce9fc5553e15218800b/prek-0.2.24-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:cbd9b7b568a5cdcb9ccce8c8b186b52c6547dfd2e70d0a2438e3cb17a37affb4", size = 5445865, upload-time = "2025-12-23T03:59:12.684Z" }, - { url = "https://files.pythonhosted.org/packages/67/61/d54c7db0f6ff1a12b0b7211b32b7b2685fcee81dd51fb1a139e757b648cd/prek-0.2.24-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fc788a1bb3dba31c9ad864ee73fc6320c07fd0f0a3d9652995dfee5d62ccc4f8", size = 5401392, upload-time = "2025-12-23T03:59:24.181Z" }, - { url = "https://files.pythonhosted.org/packages/5a/61/cd7e78e2f371a6603c6ac323ad2306c6793d39f4f6ee2723682b25d65478/prek-0.2.24-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1ee8d1293755f6b42e7fa4bbc7122781e7c3880ca06ed2f85f0ed40c0df14c9b", size = 5492942, upload-time = "2025-12-23T03:59:14.367Z" }, - { url = "https://files.pythonhosted.org/packages/10/ff/657c6269d65dbe682f82113620823c65e002c3ae4fd417f25adaa390179e/prek-0.2.24-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:933a49f0b22abc2baca378f02b4b1b6d9522800a2ccc9e247aa51ebe421fc6dc", size = 5083804, upload-time = "2025-12-23T03:59:28.213Z" }, - { url = "https://files.pythonhosted.org/packages/bc/d9/8929b12dd8849d4d00b6c8e22db1fec22fef4b1e7356c0812107eb0a4f6c/prek-0.2.24-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:f88defe48704eea1391e29b18b363fcd22ef5490af619b6328fece8092c9d24b", size = 4819786, upload-time = "2025-12-23T03:59:32.053Z" }, - { url = "https://files.pythonhosted.org/packages/db/a4/d9e0f7d445621a5c416a8883a33b079cf2c6f7e35a360d15c074f9b353fb/prek-0.2.24-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:3fd336eb13489460da3476bfb1bd185d6bd0f9d3f9bff7780b32d2c801026578", size = 4829112, upload-time = "2025-12-23T03:59:22.546Z" }, - { url = "https://files.pythonhosted.org/packages/10/da/4fdcd158268c337ad3fe4dad3fcb0716f46bba2fe202ee03a473e3eda9b9/prek-0.2.24-py3-none-musllinux_1_1_armv7l.whl", hash = "sha256:9eb952540fd17d540373eb4239ccdcc1e060ca1c33a7ec5d27f6ec03838848c5", size = 4698341, upload-time = "2025-12-23T03:59:11.184Z" }, - { url = "https://files.pythonhosted.org/packages/71/82/c9dd71e5c40c075314b6e3584067084dfbf56d9d1d74baea217d7581a5bf/prek-0.2.24-py3-none-musllinux_1_1_i686.whl", hash = "sha256:7168d6d86576704cddb7c38aff1b62c305312700492c85ff981dfa986013c265", size = 4917027, upload-time = "2025-12-23T03:59:30.751Z" }, - { url = "https://files.pythonhosted.org/packages/ef/05/0559b0504d39dc97f71d74f270918d043f3259fff4cbe11beccfdbb586e6/prek-0.2.24-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:4e500beb902c524b48d084deabc687cb344226ce91f926c6ab8a65a6754d8a9a", size = 5192231, upload-time = "2025-12-23T03:59:16.775Z" }, - { url = "https://files.pythonhosted.org/packages/1f/b3/e740f52236a0077890a82e1c8046d4e0ff8b140bd3c30e3e82f35fee2224/prek-0.2.24-py3-none-win32.whl", hash = "sha256:bab279d54b6adf85d95923590dacaa9956eb354cc64204c45983fa2d5c2f7a8a", size = 4603284, upload-time = "2025-12-23T03:59:15.544Z" }, - { url = "https://files.pythonhosted.org/packages/41/31/cf0773b3cd7b965a7d15264ec96f85ee5f451db5e9df5d0d9d87d3b8e4ce/prek-0.2.24-py3-none-win_amd64.whl", hash = "sha256:c89ad7f73e8b38bd5e79e83fec3bf234dec87295957c94cc7d94a125bc609ff0", size = 5295275, upload-time = "2025-12-23T03:59:25.354Z" }, - { url = "https://files.pythonhosted.org/packages/97/34/b44663946ea7be1d0b1c7877e748603638a8d0eff9f3969f97b9439aa17b/prek-0.2.24-py3-none-win_arm64.whl", hash = "sha256:9257b3293746a69d600736e0113534b3b80a0ce8ee23a1b0db36253e9c7e24ab", size = 4962129, upload-time = "2025-12-23T03:59:08.609Z" }, +version = "0.2.25" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bf/9c/839712da131cbbb8727f55a3908efac93db81cb25769ba9a9e3a3f0ec864/prek-0.2.25.tar.gz", hash = "sha256:0ec0d67d1df64b34f071acee7bb1507d062f0231049c0b6587ec60f3bc761ee6", size = 281000, upload-time = "2025-12-26T16:47:27.413Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/01/64/16ac112dbcc96579324e6053dd182d1383703b776e3eaaf9ce105e3d854f/prek-0.2.25-py3-none-linux_armv6l.whl", hash = "sha256:a85edf16c9a8aca13842c365be62911fbca38cd27ea7c9c54b6d3168a5b21703", size = 4796650, upload-time = "2025-12-26T16:47:14.548Z" }, + { url = "https://files.pythonhosted.org/packages/0b/87/adf8840b12135dab0dc3c3f6689569db13f273cf4df1d4fd009d117fc8a0/prek-0.2.25-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:c6ca24d8ab728f0d5b116576114df1c679bed59501c1ab71d9f2c78230f6b38c", size = 4895083, upload-time = "2025-12-26T16:47:16.531Z" }, + { url = "https://files.pythonhosted.org/packages/2d/4d/37b144b975c15901459761692c1090ab5112346157a8cd4326ce68ee3e09/prek-0.2.25-py3-none-macosx_11_0_arm64.whl", hash = "sha256:470373eba87baffe68bbbe18a4c4a85acba2709a8e834adad0c6147977ccdfb3", size = 4621901, upload-time = "2025-12-26T16:47:01.354Z" }, + { url = "https://files.pythonhosted.org/packages/fc/14/ff1d57e7322f08048ee9117497814a8ab47e10ec4f00f77bdf9880509ffe/prek-0.2.25-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:9f50ae59fd33a45a58af0197a91c9a207a7f8f49e18e24ca6ca3f5d5cf88a4ac", size = 4820856, upload-time = "2025-12-26T16:47:22.075Z" }, + { url = "https://files.pythonhosted.org/packages/3b/9c/78c00fd51bf0038cb8e828418640e98e300db81d3215f28eb699cb9a0e60/prek-0.2.25-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0e74c8ebc4cc07000b588b05df22086e3ef5ce9843c7332b9cf52bdb734378b8", size = 4717602, upload-time = "2025-12-26T16:47:20.352Z" }, + { url = "https://files.pythonhosted.org/packages/a0/50/9e9af1a0f25d280c53ef386eca035ea4b12eaeadf9419bbc69e430c840df/prek-0.2.25-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6da53de6119ec176673c4e3843abe4b6cc7190adc005564ad9e2d8b2924b3934", size = 5039527, upload-time = "2025-12-26T16:47:06.873Z" }, + { url = "https://files.pythonhosted.org/packages/89/6b/22e87200b1888cb8fc92c48996a4c03149bedddd864db7418b326c6ebfd9/prek-0.2.25-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:442994797aee8a1563f7236b54bb1d99578143b30cc4559011d59a112cdf43f3", size = 5449809, upload-time = "2025-12-26T16:47:03.379Z" }, + { url = "https://files.pythonhosted.org/packages/6f/ed/ebb63821f6c2307219bc49c914b13c89e79850c1be6d9a35fc440227666f/prek-0.2.25-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:35b3d8543969a03775f5963b8f6e957e9eb23bf191c76d47238557308e7b6bf6", size = 5408252, upload-time = "2025-12-26T16:47:18.713Z" }, + { url = "https://files.pythonhosted.org/packages/2d/9c/1638891243b4682daf790aaa7d9ec16d63dde9ab39a0a0191a3f83647e60/prek-0.2.25-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7809d7f6119be8870a2a76c15d28a122efb1f356909f355461b856619f7456fb", size = 5503319, upload-time = "2025-12-26T16:47:10.927Z" }, + { url = "https://files.pythonhosted.org/packages/ca/f0/5924037622520463f016356f5d6e9c140478bc8fb9b0230b38eeb5eea183/prek-0.2.25-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:57db60d6e7882e1b0d6b0a2e6e4b8c240977b9309b4be0793b2d7151021f3767", size = 5092919, upload-time = "2025-12-26T16:47:12.921Z" }, + { url = "https://files.pythonhosted.org/packages/17/d6/1ca7f639866a04d8b7b01e8e46da214b27e8dece98a8d854c43b41e50f90/prek-0.2.25-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:2cdedc528e935f01b97a7459b68b4f7584f8efcfc1b69d271a2a1bc3d6a60d36", size = 4826998, upload-time = "2025-12-26T16:47:05.058Z" }, + { url = "https://files.pythonhosted.org/packages/5d/de/9dd50fb437fa7c150e8c56468e7c103b0ddca0a1d11a4371785cdc96fa16/prek-0.2.25-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:68458ec5d8cadb18667d5126b6a98c0fd2214b624805935c90213d9205378dc8", size = 4835330, upload-time = "2025-12-26T16:47:25.809Z" }, + { url = "https://files.pythonhosted.org/packages/e0/e6/8a27781a1e88063afce9b9602833c210577261bbc53576bbec0e83a9a8f0/prek-0.2.25-py3-none-musllinux_1_1_armv7l.whl", hash = "sha256:7b8fa764a3665ab38884e2c909f3297e5c29137cafc9c409c1eaab734d7eefcd", size = 4703194, upload-time = "2025-12-26T16:47:34.503Z" }, + { url = "https://files.pythonhosted.org/packages/22/43/03186172e33f235261e942549f3cda351dfe8fa564ca69ad065f6de39a7f/prek-0.2.25-py3-none-musllinux_1_1_i686.whl", hash = "sha256:4073a368e949a117d77fcdbce13ff14a001b71e797fa35ec921892714bcfb389", size = 4924956, upload-time = "2025-12-26T16:47:32.871Z" }, + { url = "https://files.pythonhosted.org/packages/1f/cc/cbcecd7d6a3ccae74b9df3d14b2d4c92b9aa763eec3dc4349677f2219d3b/prek-0.2.25-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:401d33d1f54f62489b95e7aaacb9cdecac2ab61fe0bd607c8a6c11963e6ad2b9", size = 5200290, upload-time = "2025-12-26T16:47:08.751Z" }, + { url = "https://files.pythonhosted.org/packages/2f/ee/1779e94664cb0ffc0d751a04f0e4405084f38edfbdac2cde7d9bdf9353ab/prek-0.2.25-py3-none-win32.whl", hash = "sha256:3d0b9d5fb93cb679ef486f8e6c7ec091723d610d48a5430ef5ece22d649ae686", size = 4618371, upload-time = "2025-12-26T16:47:23.849Z" }, + { url = "https://files.pythonhosted.org/packages/05/8c/d807f6a6914d4262fa29d8d3834f4f0600be44cb280b19c7777790de2bb3/prek-0.2.25-py3-none-win_amd64.whl", hash = "sha256:fbcdeb1d847a0e7ba6a250d4f71be2eb1773d54dd9bb14e35584b69a8d3ffce6", size = 5307946, upload-time = "2025-12-26T16:47:31.172Z" }, + { url = "https://files.pythonhosted.org/packages/69/ff/5e2cb72168e9dd71282b8b0c58abd5c7bf0bf8635612d24fcf8273d2e306/prek-0.2.25-py3-none-win_arm64.whl", hash = "sha256:b2692991046cb32f0ef7e02e49842858c87e915cf811aa3c0f473b2c073d9c67", size = 4973841, upload-time = "2025-12-26T16:47:29.413Z" }, ] [[package]] From ec24dc2957140ce4cd65c170f5f02bcbc4da9e6e Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Sun, 28 Dec 2025 16:20:02 +0000 Subject: [PATCH 6/7] Make command_name optional --- cogs/command_error.py | 4 ++-- utils/tex_bot_base_cog.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cogs/command_error.py b/cogs/command_error.py index b7e11de7..fcdc514e 100644 --- a/cogs/command_error.py +++ b/cogs/command_error.py @@ -72,7 +72,7 @@ async def on_application_command_error( if isinstance(error, discord.ApplicationCommandInvokeError) and isinstance( error.original, GuildDoesNotExistError ): - command_name: str = ( + command_name: str | None = ( ( ctx.command.callback.__name__ if ( @@ -82,7 +82,7 @@ async def on_application_command_error( else ctx.command.qualified_name ) if ctx.command - else "UnknownCommand" + else None ) logger.critical( " ".join( diff --git a/utils/tex_bot_base_cog.py b/utils/tex_bot_base_cog.py index cc16befe..5aabc607 100644 --- a/utils/tex_bot_base_cog.py +++ b/utils/tex_bot_base_cog.py @@ -81,7 +81,7 @@ async def command_send_error( The constructed error message is then sent as the response to the given application command context. """ - COMMAND_NAME: Final[str] = ( + command_name: str | None = ( ( ctx.command.callback.__name__ if ( @@ -91,13 +91,13 @@ async def command_send_error( else ctx.command.qualified_name ) if ctx.command - else "UnknownCommand" + else None ) await self.send_error( self.bot, ctx.interaction, - interaction_name=COMMAND_NAME, + interaction_name=command_name, error_code=error_code, message=message, logging_message=logging_message, @@ -108,7 +108,7 @@ async def send_error( cls, bot: "TeXBot", interaction: discord.Interaction, - interaction_name: str, + interaction_name: str | None, error_code: str | None = None, message: str | None = None, logging_message: str | BaseException | None = None, @@ -128,7 +128,7 @@ async def send_error( f"{error_code}**\n" ) + construct_error_message - if interaction_name in cls.ERROR_ACTIVITIES: + if interaction_name and interaction_name in cls.ERROR_ACTIVITIES: construct_error_message += ( f" when trying to {cls.ERROR_ACTIVITIES[interaction_name]}" ) From 2aac9e003eb855e7e82354b19f32fda929893173 Mon Sep 17 00:00:00 2001 From: Matt Norton Date: Tue, 30 Dec 2025 00:33:10 +0000 Subject: [PATCH 7/7] Fix py-cord bump Signed-off-by: Matt Norton --- pyproject.toml | 2 +- uv.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cbfcac74..c8e22bbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ main = [ "matplotlib>=3.10", "mplcyberpunk>=0.7", "parsedatetime>=2.6", - "py-cord>=2.6,<2.7", + "py-cord>=2.7", "python-dotenv>=1.0", "python-logging-discord-handler>=0.1", "typed_classproperties>=1.2", diff --git a/uv.lock b/uv.lock index 984b2e63..d08f3e97 100644 --- a/uv.lock +++ b/uv.lock @@ -1063,7 +1063,7 @@ main = [ { name = "matplotlib", specifier = ">=3.10" }, { name = "mplcyberpunk", specifier = ">=0.7" }, { name = "parsedatetime", specifier = ">=2.6" }, - { name = "py-cord", specifier = ">=2.6,<2.7" }, + { name = "py-cord", specifier = ">=2.7" }, { name = "python-dotenv", specifier = ">=1.0" }, { name = "python-logging-discord-handler", specifier = ">=0.1" }, { name = "typed-classproperties", specifier = ">=1.2" },