Skip to content

Commit

Permalink
[Fix] User count display, slash commands setting (#176)
Browse files Browse the repository at this point in the history
* - Fix Tautulli user count setting parser (should close #170)
* - Fix slash commands registration, respect setting, remove if commands deactivated
  • Loading branch information
nwithan8 authored Mar 19, 2024
1 parent ba5bb69 commit 27711d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
20 changes: 9 additions & 11 deletions modules/discord/command_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,17 @@ def is_admin(self, interaction: discord.Interaction) -> bool:
return str(interaction.user.id) in self._admin_ids

async def register_slash_commands(self):
for cog in self._cogs_to_add:
await self._add_cog(cog)

logging.info("Slash commands registered.")

async def activate_slash_commands(self):
if not self._enable_slash_commands:
logging.info("Slash commands not enabled. Skipping activation.")
return
if self._enable_slash_commands:
for cog in self._cogs_to_add:
await self._add_cog(cog)
logging.info("Slash commands registered.")
else:
logging.info("Slash commands not enabled. Skipping registration...")

# Need to sync regardless (either adding newly-registered cogs or syncing/removing existing ones)
if not self._synced:
await self._bot.tree.sync(guild=self._guild)
self._synced = True
logging.info("Slash commands activated.")
logging.info("Slash commands synced.")
else:
logging.info("Slash commands already activated.")
logging.info("Slash commands already synced.")
3 changes: 0 additions & 3 deletions modules/discord/discord_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,6 @@ async def on_ready(self) -> None:
logging.info('Setting up Discord slash commands...')
await self.command_manager.register_slash_commands()

logging.info("Activating Discord slash commands...")
await self.command_manager.activate_slash_commands()

logging.info("Setting bot status...")
await self.client.change_presence(
activity=discord.Activity(type=discord.ActivityType.watching, name='for Tautulli stats'))
Expand Down
1 change: 1 addition & 0 deletions modules/settings/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ def allow_analytics(self) -> bool:
def _performance(self) -> ConfigSection:
return self._get_subsection(key="Performance")

@property
def _performance_monitor_tautulli_user_count(self) -> bool:
value = self._performance._get_value(key="TautulliUserCount", default=False,
env_name_override="TC_MONITOR_TAUTULLI_USER_COUNT")
Expand Down

0 comments on commit 27711d7

Please sign in to comment.