Fixed channel for get channel name can be None #362

This commit is contained in:
Sven Heidemann 2023-09-24 19:57:12 +02:00
parent 9226a1188e
commit f72ea68f66
2 changed files with 8 additions and 2 deletions

View File

@ -39,7 +39,10 @@ class UserJoinedVoiceChannel(TableABC):
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def channel_name(self, bot: DiscordBotServiceABC) -> str: def channel_name(self, bot: DiscordBotServiceABC) -> str:
return bot.get_channel(self.channel_id).name channel = bot.get_channel(self.channel_id)
if channel is None:
return ""
return channel.name
@property @property
def user(self) -> User: def user(self) -> User:

View File

@ -41,7 +41,10 @@ class UserJoinedVoiceChannelHistory(HistoryTableABC):
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def channel_name(self, bot: DiscordBotServiceABC) -> str: def channel_name(self, bot: DiscordBotServiceABC) -> str:
return bot.get_channel(self.channel_id).name channel = bot.get_channel(self.channel_id)
if channel is None:
return ""
return channel.name
@property @property
def user(self) -> int: def user(self) -> int: