Skip to content

Commit

Permalink
Fix raffles and polls not loading properly after cog reload
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsMestro committed Nov 28, 2023
1 parent d6b10c0 commit 7829c83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions utility/polls.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ def embed(self, value: discord.Embed) -> None:

@property
def guild_id(self) -> Optional[int]:
if self._guild_id is None and self._guild is not None:
return self._guild.id

return self._guild_id

@guild_id.setter
Expand Down Expand Up @@ -668,7 +671,7 @@ async def load_polls(self) -> None:
log.error("Error during poll initialization", exc_info=True)

async def poll_timer(self, poll: Poll) -> None:
await asyncio.sleep(poll.timedelta.total_seconds())
await asyncio.sleep(int(poll.timedelta.total_seconds()))

guild = self.bot.get_guild(poll.guild_id)
if guild is None:
Expand Down Expand Up @@ -715,7 +718,7 @@ async def send_results(self, poll: Poll, message: discord.Message) -> None:
poll_embed.set_field_at(
index=1, name="Ended", value=poll_embed.fields[1].value, inline=False
)
poll_embed.set_footer(text=f"Guild polls brought to you by {poll.guild.me.display_name}!")
poll_embed.set_footer(text=f"Guild polls brought to you by {poll.guild.me.name}!")

description = poll_embed.description.splitlines()
description_dicts: List[Dict[str, Union[int, str]]] = []
Expand Down
7 changes: 5 additions & 2 deletions utility/raffles.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def winners(self, value: List[int]) -> None:

@property
def guild_id(self) -> Optional[int]:
if self._guild_id is None and self._guild is not None:
return self._guild.id

return self._guild_id

@guild_id.setter
Expand Down Expand Up @@ -850,7 +853,7 @@ async def raffle_selection(
return result

async def raffle_timer(self, raffle: Raffle) -> None:
await asyncio.sleep(raffle.timedelta.total_seconds())
await asyncio.sleep(int(raffle.timedelta.total_seconds()))

guild = self.bot.get_guild(raffle.guild_id)
if guild is None:
Expand Down Expand Up @@ -1026,7 +1029,7 @@ async def get_finished_raffle_embed(
value=f"<t:{end_timestamp}:D> ◈ <t:{end_timestamp}:R>",
inline=False,
)
raffle_embed.set_footer(text=f"Guild raffles brought to you by {guild.me.display_name}!")
raffle_embed.set_footer(text=f"Guild raffles brought to you by {guild.me.name}!")

return raffle_embed

Expand Down

0 comments on commit 7829c83

Please sign in to comment.