Skip to content

Commit

Permalink
Merge pull request #196 from davidhozic/feature/bug_195
Browse files Browse the repository at this point in the history
Fixed bug #195
  • Loading branch information
davidhozic authored Sep 25, 2022
2 parents 13a4f28 + c1c1f84 commit 316ed40
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/daf/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ async def initialize(self, getter: Callable) -> None:

if self.apiobject is not None:
for message in self._messages_uninitialized:
await self.add_message(message)
try:
await self.add_message(message)
except (TypeError, ValueError, DAFError) as exc:
trace(f"[GUILD:] Unable to initialize message {message}, in {self}\nReason: {exc}", TraceLEVELS.WARNING)


self._messages_uninitialized.clear()
return
Expand Down
4 changes: 2 additions & 2 deletions src/daf/message/text_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ async def initialize(self, parent: Any):
ch_i += 1

if not len(self.channels):
raise ValueError(f"No valid channels were passed to {type(self)} object")
raise ValueError(f"No valid channels were passed to {self} object")

async def _handle_error(self, channel: Union[discord.TextChannel, discord.Thread], ex: Exception) -> bool:
"""
Expand Down Expand Up @@ -330,7 +330,7 @@ async def _send_channel(self,

# Check if channel still exists in cache (has not been deleted)
if client.get_client().get_channel(channel.id) is None:
ex = self._generate_exception(404, 10003, "Channel was deleted", discord.NotFound)
raise self._generate_exception(404, 10003, "Channel was deleted", discord.NotFound)

# Delete previous message if clear-send mode is chosen and message exists
if self.mode == "clear-send" and self.sent_messages.get(channel.id, None) is not None:
Expand Down
4 changes: 2 additions & 2 deletions src/daf/message/voice_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async def initialize(self, parent: Any):
ch_i += 1

if not len(self.channels):
raise ValueError(f"No valid channels were passed to {type(self)} object")
raise ValueError(f"No valid channels were passed to {self} object")

async def _send_channel(self,
channel: discord.VoiceChannel,
Expand Down Expand Up @@ -275,7 +275,7 @@ async def _send_channel(self,

# Check if channel still exists in cache (has not been deleted)
if client.get_client().get_channel(channel.id) is None:
ex = self._generate_exception(404, 10003, "Channel was deleted", discord.NotFound)
raise self._generate_exception(404, 10003, "Channel was deleted", discord.NotFound)

if GLOBALS.voice_client is None or not GLOBALS.voice_client.is_connected():
GLOBALS.voice_client = await channel.connect(timeout=C_VC_CONNECT_TIMEOUT)
Expand Down

0 comments on commit 316ed40

Please sign in to comment.