Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replying to bot #99

Merged
merged 3 commits into from
Aug 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

DEPLOYMENT_DATE = datetime.datetime.now()


class BotInitialiser:
def __init__(self):
self.client = bot.get_bot(IS_PROD)
Expand All @@ -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",
Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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 = []
Expand All @@ -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(
Expand All @@ -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()
discord_bot.run()
Loading