From a894c47a8a89cb527c43318a2a6764dbe5955e7b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 3 Jan 2026 22:01:27 +0000 Subject: [PATCH 1/2] Initial plan From b0c16687b8427416be6b5f41c46dd1b5c87fc979 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 3 Jan 2026 22:05:40 +0000 Subject: [PATCH 2/2] Remove duplicate bot.process_commands() call and add explanatory comments Co-authored-by: Rajrooter <128113526+Rajrooter@users.noreply.github.com> --- main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 3c62b57..d0af7f0 100644 --- a/main.py +++ b/main.py @@ -531,7 +531,8 @@ async def on_message(self, message): return self.processed_messages.add(message.id) - await self.bot.process_commands(message) + # NOTE: Do NOT call bot.process_commands() here - Discord.py handles this automatically + # Calling it here would cause all commands to execute twice if len(self.processed_messages) > 1000: self.processed_messages = set(list(self.processed_messages)[-1000:]) @@ -1216,10 +1217,17 @@ async def on_command_error(ctx, error): print(f"Error: {error}") async def main(): + """Main entry point for the bot. + + NOTE: The LinkManager cog is added here inside main() rather than at the module level + to avoid duplicate listeners and side effects on import. This ensures the cog is only + registered once, preventing duplicate command execution and event handling. + """ token = os.getenv('DISCORD_TOKEN') if not token: raise ValueError("DISCORD_TOKEN not set!") async with bot: + # Add the LinkManager cog exactly once to avoid duplicate command execution await bot.add_cog(LinkManager(bot)) await bot.start(token)