From 74d30868d1ec6e9a6caa2c7b830302bb2d49c18a Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 16:28:09 +0530 Subject: [PATCH 1/9] Uncommented working code, added missing await and a check for messages from a moderator --- .../cogs/verification/verification_on_join.py | 61 ++++++++++--------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/src/bot/cogs/verification/verification_on_join.py b/src/bot/cogs/verification/verification_on_join.py index bc74cdc..65c2396 100644 --- a/src/bot/cogs/verification/verification_on_join.py +++ b/src/bot/cogs/verification/verification_on_join.py @@ -89,34 +89,39 @@ async def on_member_join(self, member: discord.Member): # Is being called even though it should not be. # await self.kick_if_not_verified(member, 3600, verification_log) - # @commands.Cog.listener() - # async def on_message(self, message): - # """ - # Keep verification clean again - # """ - # if message.author.guild.id != int(os.getenv("MASTER_GUILD")): - # logger.warning("on_message in verification fired, but not in master guild. Ignoring event.") - # return - # - # if message.channel.id == int(self.verification_channel): - # if not message.author.bot: - # if f"{os.getenv('PREFIX')}verify" == message.content: # keep it exact - # # user is doing it right, and the verification_dropdown is triggered - # logger.debug(f"{message.author.name} started verification.") - # await sleep(3) - # await message.delete() # cleanup correct verification calls - # return - # else: # this covers any other message in the channel. - # await message.delete() # delete the user's incorrect message - # bot_message = await message.channel.send( - # f"You need to use the **{os.getenv('PREFIX')}verify** command.") - # - # logs_channel = await self.bot.fetch_channel(self.verification_log) - # await logs_channel.send( - # f"{message.author} is failing at life in {self.bot.get_channel(self.verification_channel)}") - # - # await sleep(8) - # bot_message.delete() # remove the message to correct people after 8? seconds + @commands.Cog.listener() + async def on_message(self, message): + """ + Keep verification clean again + """ + if message.author.guild.id != int(os.getenv("MASTER_GUILD")): + logger.warning("on_message in verification fired, but not in master guild. Ignoring event.") + return + + if message.channel.id == int(self.verification_channel): + if ( + not message.author.bot and + not (message.author.guild_permissions.administrator or message.author.guild_permissions.ban_member) + ): + if f"{os.getenv('PREFIX')}verify" == message.content: # keep it exact + # user is doing it right, and the verification_dropdown is triggered + logger.debug(f"{message.author.name} started verification.") + await sleep(3) + await message.delete() # cleanup correct verification calls + return + else: # this covers any other message in the channel. + await message.delete() # delete the user's incorrect message + bot_message = await message.channel.send( + f"You need to use the **{os.getenv('PREFIX')}verify** command." + ) + + logs_channel = await self.bot.fetch_channel(self.verification_log) + await logs_channel.send( + f"{message.author} is failing at life in {self.bot.get_channel(int(self.verification_channel)).mention}" + ) + + await sleep(8) + await bot_message.delete() # remove the message to correct people after 8? seconds async def setup(bot: commands.Bot) -> None: From c4f57c0ff8ba9ada5724ae4e53d3b24b895a5b03 Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 16:30:52 +0530 Subject: [PATCH 2/9] Fixed message deletion and comparison of string id with int ids --- src/bot/cogs/verification/verification_dropdown.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bot/cogs/verification/verification_dropdown.py b/src/bot/cogs/verification/verification_dropdown.py index 9ae76ce..7c31a73 100644 --- a/src/bot/cogs/verification/verification_dropdown.py +++ b/src/bot/cogs/verification/verification_dropdown.py @@ -89,7 +89,7 @@ async def callback(self, interaction: discord.Interaction): except AttributeError as no_role_set: await verification_log.send( - f"{interaction.user.display_name} is trying to verify, but there is no " + f"{interaction.user.display_name} is trying to verify, but there is no" f"verification role set!" ) logger.critical(no_role_set) @@ -97,13 +97,13 @@ async def callback(self, interaction: discord.Interaction): "Someone is verifying, but there is no verification role set!" ) else: - msg = await interaction.response.send_message("You are a robot? Nice try.") + response = await interaction.response.send_message("You are a robot? Nice try.") await verification_log.send( - f"{interaction.user.display_name} admitted to being a robot, and was kicked. " + f"{interaction.user.display_name} admitted to being a robot, and was kicked." ) sleep(3) + await response.resource.delete() await interaction.user.kick(reason="User admitted to being a robot.") - await msg.delete() class DropdownView(discord.ui.View): @@ -141,7 +141,7 @@ async def verify(self, ctx): return else: - if self.verified_role not in [role.id for role in ctx.author.roles]: + if int(self.verified_role) not in [role.id for role in ctx.author.roles]: logger.debug(f"{ctx.author.name} is attempting to verify") await ctx.send( "# ~ Verification ~ \n" @@ -151,7 +151,9 @@ async def verify(self, ctx): delete_after=15.0, ) else: - await ctx.send("You are already verified. Go away.") + msg = await ctx.send("You are already verified. Go away.") + sleep(10) + await msg.delete() async def setup(bot: commands.Bot) -> None: From d81faf0e6cfb7d06fedd2d79db992dc84008d139 Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 16:32:11 +0530 Subject: [PATCH 3/9] Skip logging deleted messages from verification process --- src/bot/cogs/logging/logging_message_delete.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/bot/cogs/logging/logging_message_delete.py b/src/bot/cogs/logging/logging_message_delete.py index 154fe01..75a2fa2 100644 --- a/src/bot/cogs/logging/logging_message_delete.py +++ b/src/bot/cogs/logging/logging_message_delete.py @@ -68,6 +68,12 @@ def __init__(self, bot): raise RuntimeError("Failed to fetch staff channel setting from API.") self.staff_channel = setting["setting"]["value"] + setting = self.bot.api.get_one_setting("1") # Verification Channel ID + if setting["status"] != "ok": + raise RuntimeError("Failed to fetch verification channel setting from API.") + self.verification_channel = setting["setting"]["value"] + self.verification_command = f"{os.getenv("PREFIX")}verify" + self.chat_log = self.bot.api.get_one_log_setting("3") # chat_log if self.chat_log["status"] != "ok": raise RuntimeError("Failed to fetch chat log setting from API.") @@ -125,10 +131,19 @@ async def on_message_delete(self, message) -> None: ) return - if message.channel.id == self.staff_channel: + if message.channel.id == int(self.staff_channel): logger.debug("Message delete in staff channel was ignored.") return + if ( + message.channel.id == int(self.verification_channel) and ( + message.author.bot or + message.content == self.verification_command + ) + ): + logger.debug("Message from verification process was ignored.") + return + audit_log = [entry async for entry in message.guild.audit_logs(limit=1)][0] if self.chat_log["status"] == "ok": if self.chat_log["log_setting"]["value"] == "0": From 386748c38b48034ae288653995a24ac0bcd78746 Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 16:41:05 +0530 Subject: [PATCH 4/9] Fixed a typo and a bit of formatting --- src/bot/cogs/logging/logging_message_delete.py | 7 ++++--- src/bot/cogs/verification/verification_on_join.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bot/cogs/logging/logging_message_delete.py b/src/bot/cogs/logging/logging_message_delete.py index 75a2fa2..40f28f5 100644 --- a/src/bot/cogs/logging/logging_message_delete.py +++ b/src/bot/cogs/logging/logging_message_delete.py @@ -136,9 +136,10 @@ async def on_message_delete(self, message) -> None: return if ( - message.channel.id == int(self.verification_channel) and ( - message.author.bot or - message.content == self.verification_command + message.channel.id == int(self.verification_channel) + and ( + message.author.bot + or message.content == self.verification_command ) ): logger.debug("Message from verification process was ignored.") diff --git a/src/bot/cogs/verification/verification_on_join.py b/src/bot/cogs/verification/verification_on_join.py index 65c2396..e089242 100644 --- a/src/bot/cogs/verification/verification_on_join.py +++ b/src/bot/cogs/verification/verification_on_join.py @@ -100,8 +100,8 @@ async def on_message(self, message): if message.channel.id == int(self.verification_channel): if ( - not message.author.bot and - not (message.author.guild_permissions.administrator or message.author.guild_permissions.ban_member) + not message.author.bot + and not (message.author.guild_permissions.administrator or message.author.guild_permissions.ban_members) ): if f"{os.getenv('PREFIX')}verify" == message.content: # keep it exact # user is doing it right, and the verification_dropdown is triggered From 06a2f35f3448ee5bccbc166bec653c3d2bb42d4e Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 16:58:13 +0530 Subject: [PATCH 5/9] Ruff pre-commit changes --- src/bot/cogs/logging/logging_message_delete.py | 8 ++------ src/bot/cogs/verification/verification_dropdown.py | 4 +++- src/bot/cogs/verification/verification_on_join.py | 14 +++++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/bot/cogs/logging/logging_message_delete.py b/src/bot/cogs/logging/logging_message_delete.py index 40f28f5..5673219 100644 --- a/src/bot/cogs/logging/logging_message_delete.py +++ b/src/bot/cogs/logging/logging_message_delete.py @@ -135,12 +135,8 @@ async def on_message_delete(self, message) -> None: logger.debug("Message delete in staff channel was ignored.") return - if ( - message.channel.id == int(self.verification_channel) - and ( - message.author.bot - or message.content == self.verification_command - ) + if message.channel.id == int(self.verification_channel) and ( + message.author.bot or message.content == self.verification_command ): logger.debug("Message from verification process was ignored.") return diff --git a/src/bot/cogs/verification/verification_dropdown.py b/src/bot/cogs/verification/verification_dropdown.py index 7c31a73..883fa2a 100644 --- a/src/bot/cogs/verification/verification_dropdown.py +++ b/src/bot/cogs/verification/verification_dropdown.py @@ -97,7 +97,9 @@ async def callback(self, interaction: discord.Interaction): "Someone is verifying, but there is no verification role set!" ) else: - response = await interaction.response.send_message("You are a robot? Nice try.") + response = await interaction.response.send_message( + "You are a robot? Nice try." + ) await verification_log.send( f"{interaction.user.display_name} admitted to being a robot, and was kicked." ) diff --git a/src/bot/cogs/verification/verification_on_join.py b/src/bot/cogs/verification/verification_on_join.py index e089242..2bbcecf 100644 --- a/src/bot/cogs/verification/verification_on_join.py +++ b/src/bot/cogs/verification/verification_on_join.py @@ -95,13 +95,15 @@ async def on_message(self, message): Keep verification clean again """ if message.author.guild.id != int(os.getenv("MASTER_GUILD")): - logger.warning("on_message in verification fired, but not in master guild. Ignoring event.") + logger.warning( + "on_message in verification fired, but not in master guild. Ignoring event." + ) return if message.channel.id == int(self.verification_channel): - if ( - not message.author.bot - and not (message.author.guild_permissions.administrator or message.author.guild_permissions.ban_members) + if not message.author.bot and not ( + message.author.guild_permissions.administrator + or message.author.guild_permissions.ban_members ): if f"{os.getenv('PREFIX')}verify" == message.content: # keep it exact # user is doing it right, and the verification_dropdown is triggered @@ -121,7 +123,9 @@ async def on_message(self, message): ) await sleep(8) - await bot_message.delete() # remove the message to correct people after 8? seconds + await ( + bot_message.delete() + ) # remove the message to correct people after 8? seconds async def setup(bot: commands.Bot) -> None: From 7a0094fe405288396cf44f9b80ba821e4f39b21b Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Mon, 17 Aug 2026 17:13:42 +0530 Subject: [PATCH 6/9] Fixed removal a necessary space thinking it was unnecessary --- src/bot/cogs/verification/verification_dropdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot/cogs/verification/verification_dropdown.py b/src/bot/cogs/verification/verification_dropdown.py index 883fa2a..c89355a 100644 --- a/src/bot/cogs/verification/verification_dropdown.py +++ b/src/bot/cogs/verification/verification_dropdown.py @@ -89,7 +89,7 @@ async def callback(self, interaction: discord.Interaction): except AttributeError as no_role_set: await verification_log.send( - f"{interaction.user.display_name} is trying to verify, but there is no" + f"{interaction.user.display_name} is trying to verify, but there is no " f"verification role set!" ) logger.critical(no_role_set) From 7533539b8a812e7c6a67aec80bb80171bcf5261e Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Sun, 23 Aug 2026 19:31:04 +0530 Subject: [PATCH 7/9] Replaced manual deletion of messages from bot with delete_after argument --- src/bot/cogs/verification/verification_dropdown.py | 11 +++-------- src/bot/cogs/verification/verification_on_join.py | 10 +++------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/bot/cogs/verification/verification_dropdown.py b/src/bot/cogs/verification/verification_dropdown.py index c89355a..ebd2db3 100644 --- a/src/bot/cogs/verification/verification_dropdown.py +++ b/src/bot/cogs/verification/verification_dropdown.py @@ -8,7 +8,6 @@ import datetime import logging -from time import sleep import discord from discord.ext import commands @@ -97,14 +96,12 @@ async def callback(self, interaction: discord.Interaction): "Someone is verifying, but there is no verification role set!" ) else: - response = await interaction.response.send_message( - "You are a robot? Nice try." + await interaction.response.send_message( + "You are a robot? Nice try.", delete_after=3.0 ) await verification_log.send( f"{interaction.user.display_name} admitted to being a robot, and was kicked." ) - sleep(3) - await response.resource.delete() await interaction.user.kick(reason="User admitted to being a robot.") @@ -153,9 +150,7 @@ async def verify(self, ctx): delete_after=15.0, ) else: - msg = await ctx.send("You are already verified. Go away.") - sleep(10) - await msg.delete() + await ctx.send("You are already verified. Go away.", delete_after=10.0) async def setup(bot: commands.Bot) -> None: diff --git a/src/bot/cogs/verification/verification_on_join.py b/src/bot/cogs/verification/verification_on_join.py index 2bbcecf..4cfedf7 100644 --- a/src/bot/cogs/verification/verification_on_join.py +++ b/src/bot/cogs/verification/verification_on_join.py @@ -113,8 +113,9 @@ async def on_message(self, message): return else: # this covers any other message in the channel. await message.delete() # delete the user's incorrect message - bot_message = await message.channel.send( - f"You need to use the **{os.getenv('PREFIX')}verify** command." + await message.channel.send( + f"You need to use the **{os.getenv('PREFIX')}verify** command.", + delete_after=8.0, ) logs_channel = await self.bot.fetch_channel(self.verification_log) @@ -122,11 +123,6 @@ async def on_message(self, message): f"{message.author} is failing at life in {self.bot.get_channel(int(self.verification_channel)).mention}" ) - await sleep(8) - await ( - bot_message.delete() - ) # remove the message to correct people after 8? seconds - async def setup(bot: commands.Bot) -> None: """boink""" From ee6a61c02a29a0da9f48a37ffe6842996b51cb00 Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Sun, 23 Aug 2026 19:32:56 +0530 Subject: [PATCH 8/9] Skipping messages sent in DM for verification --- src/bot/cogs/verification/verification_on_join.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bot/cogs/verification/verification_on_join.py b/src/bot/cogs/verification/verification_on_join.py index 4cfedf7..6b3ff29 100644 --- a/src/bot/cogs/verification/verification_on_join.py +++ b/src/bot/cogs/verification/verification_on_join.py @@ -94,6 +94,10 @@ async def on_message(self, message): """ Keep verification clean again """ + if isinstance(message.channel, discord.channel.DMChannel): + logger.info("Skipping messages in DMs.") + return + if message.author.guild.id != int(os.getenv("MASTER_GUILD")): logger.warning( "on_message in verification fired, but not in master guild. Ignoring event." From 1efcb8d0bf06305145c18fa3a01c52a2889ba27a Mon Sep 17 00:00:00 2001 From: kritarth2135 Date: Sun, 23 Aug 2026 19:43:23 +0530 Subject: [PATCH 9/9] Ruff formatting --- src/bot/cogs/logging/logging_message_delete.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot/cogs/logging/logging_message_delete.py b/src/bot/cogs/logging/logging_message_delete.py index 5673219..5d5ccfe 100644 --- a/src/bot/cogs/logging/logging_message_delete.py +++ b/src/bot/cogs/logging/logging_message_delete.py @@ -72,7 +72,7 @@ def __init__(self, bot): if setting["status"] != "ok": raise RuntimeError("Failed to fetch verification channel setting from API.") self.verification_channel = setting["setting"]["value"] - self.verification_command = f"{os.getenv("PREFIX")}verify" + self.verification_command = f"{os.getenv('PREFIX')}verify" self.chat_log = self.bot.api.get_one_log_setting("3") # chat_log if self.chat_log["status"] != "ok":