Skip to content

Commit

Permalink
- Remove default channel type for Discord causing creation errors in …
Browse files Browse the repository at this point in the history
…switch-case (#202)

- Improve logs for slash command syncing
  • Loading branch information
nwithan8 authored Apr 3, 2024
1 parent a13eebb commit 39db6bb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion modules/discord/command_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def __init__(self,
def _cogs_to_add(self):
return [
Most(bot=self._bot, tautulli=self._tautulli, admin_check=self.is_admin),
Summary(bot=self._bot, tautulli=self._tautulli, emoji_manager=self._emoji_manager, admin_check=self.is_admin),
Summary(bot=self._bot, tautulli=self._tautulli, emoji_manager=self._emoji_manager,
admin_check=self.is_admin),
Recently(bot=self._bot, tautulli=self._tautulli, admin_check=self.is_admin),
]

Expand All @@ -58,6 +59,7 @@ async def register_slash_commands(self):
logging.info("Slash commands not enabled. Skipping registration...")

# Need to sync regardless (either adding newly-registered cogs or syncing/removing existing ones)
logging.info("Syncing slash commands...")
if not self._synced:
await self._bot.tree.sync(guild=self._guild)
self._synced = True
Expand Down
3 changes: 2 additions & 1 deletion modules/discord/discord_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ async def on_ready(self) -> None:
await discord_utils.get_or_create_discord_channel_by_name(
client=self.client,
guild_id=self.guild_id,
channel_name=self.tautulli_summary_channel_name)
channel_name=self.tautulli_summary_channel_name,
channel_type=discord.ChannelType.text)
if not self.tautulli_summary_channel:
raise Exception(f"Could not load {quote(self.tautulli_summary_channel_name)} channel. Exiting...")

Expand Down
6 changes: 3 additions & 3 deletions modules/discord/discord_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def create_discord_category(client: discord.Client,
async def create_discord_channel(client: discord.Client,
guild_id: int,
channel_name: str,
channel_type: discord.ChannelType = discord.ChannelType.text,
channel_type: discord.ChannelType,
category: discord.CategoryChannel = None) -> \
Union[discord.TextChannel, discord.VoiceChannel, discord.CategoryChannel]:
match channel_type:
Expand Down Expand Up @@ -94,7 +94,7 @@ async def get_all_discord_channels(client: discord.Client,
async def get_or_create_discord_channel_by_name(client: discord.Client,
guild_id: int,
channel_name: str,
channel_type: discord.ChannelType = None,
channel_type: discord.ChannelType,
category: discord.CategoryChannel = None) -> \
Union[discord.VoiceChannel, discord.TextChannel, discord.CategoryChannel, None]:
channels = await get_all_discord_channels(client=client, guild_id=guild_id, channel_type=channel_type)
Expand All @@ -115,7 +115,7 @@ async def get_or_create_discord_channel_by_name(client: discord.Client,
async def get_or_create_discord_channel_by_starting_name(client: discord.Client,
guild_id: int,
starting_channel_name: str,
channel_type: discord.ChannelType = None,
channel_type: discord.ChannelType,
category: discord.CategoryChannel = None) -> \
Union[discord.VoiceChannel, discord.TextChannel, None]:
channels = await get_all_discord_channels(client=client, guild_id=guild_id, channel_type=channel_type)
Expand Down

0 comments on commit 39db6bb

Please sign in to comment.