Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
psykzz authored Dec 28, 2024
1 parent 5a245a0 commit 392d36d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions movie_vote/movie_vote.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,16 @@ async def _movievote_pinboard(self, ctx):
leaderboard = await ctx.send(embed=embed)
await leaderboard.pin()

leaderboard_id = await self.config.guild(message.guild).leaderboard()
if leaderboard_id:
leaderboard_msg = await message.channel.fetch_message(leaderboard_id)
await leaderboard_msg.unpin()
await leaderboard_msg.delete()
try:
leaderboard_id = await self.config.guild(ctx.guild).leaderboard()
if leaderboard_id:
leaderboard_msg = await message.channel.fetch_message(leaderboard_id)
await leaderboard_msg.unpin()
await leaderboard_msg.delete()
except:
log.error("unable to find delete and unpin previous message")
pass


# Save the leaderboard message ID so we can edit it later
await self.config.guild(ctx.guild).leaderboard.set(leaderboard.id)
Expand All @@ -279,7 +284,6 @@ async def _movievote_leaderboard(self, ctx, watched_only = True):
"""
Get the movie leaderboard.
"""

movies = await self.config.guild(ctx.guild).movies()
if not movies:
await ctx.send("No movies in the list.")
Expand All @@ -289,6 +293,8 @@ async def _movievote_leaderboard(self, ctx, watched_only = True):
if watched_only:
movies = [movie for movie in movies if not movie.get("watched", False)]

movies = sorted(movies, key=lambda x: x["score"], reverse=True)

def generate_page(movie):
title = movie.get("title", "unknown")
year = movie.get("year", "unknown")
Expand Down

0 comments on commit 392d36d

Please sign in to comment.