Refactor Dockerfile to remove platform specification and clean up main.py by consolidating user permission checks

This commit is contained in:
Joakim Hellsén 2025-08-17 04:58:23 +02:00
commit 489d8980c8
2 changed files with 4 additions and 6 deletions

View file

@ -66,7 +66,6 @@ class LoviBotClient(discord.Client):
# Only allow certain users to interact with the bot
allowed_users: list[str] = get_allowed_users()
if message.author.name not in allowed_users:
logger.info("Ignoring message from: %s", message.author.name)
return
incoming_message: str | None = message.content
@ -175,15 +174,14 @@ async def ask(interaction: discord.Interaction, text: str) -> None:
await interaction.followup.send("You need to provide a question or message.", ephemeral=True)
return
# Only allow certain users to interact with the bot
allowed_users: list[str] = get_allowed_users()
user_name_lowercase: str = interaction.user.name.lower()
logger.info("Received command from: %s", user_name_lowercase)
# Only allow certain users to interact with the bot
allowed_users: list[str] = get_allowed_users()
if user_name_lowercase not in allowed_users:
logger.info("Ignoring message from: %s", user_name_lowercase)
await interaction.followup.send("You are not allowed to use this command.", ephemeral=True)
await interaction.followup.send("You are not allowed to use this command.")
return
try: