From 75b68e45e9be79fb2c838fa44f30fd3c817fa2e4 Mon Sep 17 00:00:00 2001 From: Howard Tseng Date: Sat, 3 Aug 2024 23:12:48 -0400 Subject: [PATCH 1/3] fix: replying to bot --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index ccc2f8e..2bb6588 100644 --- a/main.py +++ b/main.py @@ -138,7 +138,7 @@ async def on_message(message: discord.Message): pass # don't respond to bot's own posts or if message reacts are disabled - if message.author == self.client.user or not message_reacts_enabled: + if message.author == self.client.user or not message_reacts_enabled or message.author.bot: return events = [] From 8a442a03a13d4016f4d676d26e6a368c87a08f0a Mon Sep 17 00:00:00 2001 From: Howard Tseng Date: Sat, 3 Aug 2024 23:24:41 -0400 Subject: [PATCH 2/3] comment --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 2bb6588..d57eaf8 100644 --- a/main.py +++ b/main.py @@ -137,7 +137,7 @@ async def on_message(message: discord.Message): # default true pass - # don't respond to bot's own posts or if message reacts are disabled + # don't respond to bots, bot's own posts or if message reacts are disabled if message.author == self.client.user or not message_reacts_enabled or message.author.bot: return From 36833752f6455fffaa309bfebcb35c3fb3c955d5 Mon Sep 17 00:00:00 2001 From: Howard Tseng Date: Sat, 3 Aug 2024 23:27:14 -0400 Subject: [PATCH 3/3] formatting --- main.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index d57eaf8..8e832ef 100644 --- a/main.py +++ b/main.py @@ -48,6 +48,7 @@ DEPLOYMENT_DATE = datetime.datetime.now() + class BotInitialiser: def __init__(self): self.client = bot.get_bot(IS_PROD) @@ -67,7 +68,6 @@ def register_commands(self): self.register_commands_in_all_servers() self.register_event_callbacks() - def register_placetw_commands(self): @self.tree.command( name="deployment-info", @@ -87,7 +87,6 @@ async def deployment_info(interaction: discord.Interaction): msg = "\n".join(msg_list) await interaction.response.send_message(msg) - # * register commands the just the placetw server edit_entry_cmd.register_commands(self.tree, self.placetw_guild, self.client) restart.register_commands(self.tree, self.placetw_guild) @@ -124,7 +123,6 @@ async def on_ready(): logging.init(self.client, DEPLOYMENT_DATE) print("Bot is ready.") - # when someone sends any message @self.client.event async def on_message(message: discord.Message): @@ -138,7 +136,11 @@ async def on_message(message: discord.Message): pass # don't respond to bots, bot's own posts or if message reacts are disabled - if message.author == self.client.user or not message_reacts_enabled or message.author.bot: + if ( + message.author == self.client.user + or not message_reacts_enabled + or message.author.bot + ): return events = [] @@ -153,7 +155,6 @@ async def on_message(message: discord.Message): if len(events) > 0: await logging.log_message_event(message, events) - @self.client.event async def on_guild_join(guild): supabaseClient.table("server_config").insert( @@ -164,11 +165,11 @@ async def on_guild_join(guild): ).execute() self.register_commands(self.tree, self.client, [guild]) await self.tree.sync(guild=guild) - def run(self): self.client.run(TOKEN) + if __name__ == "__main__": discord_bot = BotInitialiser() - discord_bot.run() \ No newline at end of file + discord_bot.run()