fix(config): add fallback to absolute imports in channel_manager.py

This commit is contained in:
pacnpal
2024-11-17 22:48:24 +00:00
parent ffb5139fdb
commit 525c7f3bed

View File

@@ -4,10 +4,18 @@ import logging
from typing import Dict, List, Optional, Tuple from typing import Dict, List, Optional, Tuple
import discord # type: ignore import discord # type: ignore
from .exceptions import ( try:
# Try relative imports first
from .exceptions import (
ConfigurationError as ConfigError, ConfigurationError as ConfigError,
DiscordAPIError, DiscordAPIError,
) )
except ImportError:
# Fall back to absolute imports if relative imports fail
from videoarchiver.config.exceptions import (
ConfigurationError as ConfigError,
DiscordAPIError,
)
logger = logging.getLogger("ChannelManager") logger = logging.getLogger("ChannelManager")
@@ -49,8 +57,6 @@ class ChannelManager:
logger.warning(f"Channel {channel_id} not found in guild {guild.id}") logger.warning(f"Channel {channel_id} not found in guild {guild.id}")
return None return None
return None
if not isinstance(channel, discord.TextChannel): if not isinstance(channel, discord.TextChannel):
raise DiscordAPIError(f"Channel {channel_id} is not a text channel") raise DiscordAPIError(f"Channel {channel_id} is not a text channel")