diff --git a/main.py b/main.py index ccc2f8e..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): @@ -137,8 +135,12 @@ async def on_message(message: discord.Message): # default true 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: + # 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 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()