diff --git a/bot/bot.py b/bot/bot.py index 0cd5abf..0d4dcec 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -109,7 +109,7 @@ class ContestBot(commands.Bot): return else: for submission in submissions: - message: discord.PartialMessage = channel.get_partial_message(submission.id) + message: discord.Message = await channel.fetch_message(submission.id) await message.add_reaction(self.get_emoji(constants.Emoji.UPVOTE)) def get_message(self, channel_id: int, message_id: int) -> discord.PartialMessage: diff --git a/bot/cogs/contest_commands.py b/bot/cogs/contest_commands.py index 6ddd99b..5176b74 100644 --- a/bot/cogs/contest_commands.py +++ b/bot/cogs/contest_commands.py @@ -121,6 +121,7 @@ class ContestCommandsCog(commands.Cog, name='Contest'): # noinspection PyDunderSlots,PyUnresolvedReferences @commands.command() @commands.guild_only() + @commands.bot_has_guild_permissions(add_reactions=True) @commands.has_permissions(send_messages=True, add_reactions=True, read_message_history=True, manage_roles=True) @commands.max_concurrency(1, per=BucketType.guild, wait=True) @checks.privileged() @@ -231,7 +232,8 @@ class ContestCommandsCog(commands.Cog, name='Contest'): embed.add_field(name='Submission Channel', value=value) if period is not None: - value = 'None' if guild.current_period is None else guild.current_period.state.name.capitalize() + value = 'None' if guild.current_period is None else \ + (guild.current_period.state.name.capitalize() if guild.current_period.active else 'Finished') embed.add_field(name='Status', inline=False, value=f'{value} - {period.permission_explanation()}') value = len(period.submissions) value = str(value) + ' submission' + ('s' if value > 1 or value == 0 else '') diff --git a/bot/models.py b/bot/models.py index b02c304..c151d92 100644 --- a/bot/models.py +++ b/bot/models.py @@ -100,13 +100,13 @@ class Submission(Base): self._votes = votes self.count = len(votes) - def __init__(self, **kwds): + def __init__(self, **kwargs): # Adds default column behavior for Mutable JSON votes column - kwds.setdefault("votes", []) - super().__init__(**kwds) + kwargs.setdefault("votes", []) + super().__init__(**kwargs) def __repr__(self) -> str: - return 'Submission(id={id}, user={user}, period={period_id}, {votes})'.format(**self.__dict__) + return 'Submission(id={id}, user={user}, period={period_id}, {count} votes)'.format(**self.__dict__) def increment(self, user: int) -> None: """Increase the number of votes by one.""" @@ -148,7 +148,7 @@ class Submission(Base): # Find what users voted for this submission that we are clearing votes = set(submission.votes) same = votes.intersection(users) - if len(same) > 0: + if len(same) == 0: continue # Remove votes from the submission by said users @@ -201,7 +201,7 @@ class Submission(Base): for reaction_marker in reaction_tuples: await message_to_clear.remove_reaction( bot.get_emoji(constants.Emoji.UPVOTE), - message.guild.get_member(reaction_marker.user) + await message.guild.fetch_member(reaction_marker.user) ) # Update the current list of votes @@ -300,7 +300,8 @@ class Period(Base): else: if self.state == PeriodStates.FINISHED: return 'Voting closed. Contest results available.' elif self.state == PeriodStates.VOTING: return 'Voting closed (prematurely). Contest results available.' - else: return 'Closed prematurely. Submissions were remembered, but no votes were cast.' + elif self.state == PeriodStates.READY: return 'Closed before any submissions could be submitted.' + else: return 'Closed prematurely. Submissions were remembered, but no votes could be cast.' return "Error." def __repr__(self) -> str: