mirror of
https://github.com/Xevion/contest-assistant.git
synced 2025-12-06 09:14:40 -06:00
Improve permission_explanation for prematurely closed Periods
- Periods closed improperly through the 'close' command were not being shown properly through the 'status' command. - Fixed error in Submission state checking in on_message handling. - Added embed support to 'close' command message responses.
This commit is contained in:
@@ -210,13 +210,13 @@ class ContestCommandsCog(commands.Cog, name='Contest'):
|
||||
period: Period = guild.current_period
|
||||
|
||||
if period is None or not period.active:
|
||||
await ctx.send('No period is currently active.')
|
||||
await ctx.send(embed=helpers.error_embed(message='No period is currently active.'))
|
||||
else:
|
||||
overwrite = discord.PermissionOverwrite()
|
||||
overwrite.send_messages = False
|
||||
overwrite.add_reactions = False
|
||||
period.deactivate()
|
||||
await ctx.send('The current period has been closed.')
|
||||
await ctx.send(embed=helpers.success_embed(message='The current period has been closed.'))
|
||||
|
||||
@commands.command()
|
||||
@commands.guild_only()
|
||||
|
||||
@@ -40,7 +40,7 @@ class ContestEventsCog(commands.Cog):
|
||||
await self.bot.reject(message, f'Each submission must contain exactly one image.')
|
||||
elif guild.current_period is None:
|
||||
await self.bot.reject(message, f'A period has not been started. Submissions should not be allowed at this moment.')
|
||||
elif guild.current_period != PeriodStates.SUBMISSIONS:
|
||||
elif guild.current_period.state != PeriodStates.SUBMISSIONS:
|
||||
logger.warning(f'Valid submission was sent outside of Submissions in'
|
||||
f' {channel.id}/{message.id}. Permissions error? Removing.')
|
||||
await message.delete()
|
||||
|
||||
@@ -292,11 +292,15 @@ class Period(Base):
|
||||
|
||||
def permission_explanation(self) -> str:
|
||||
"""Returns a quick explanation of the period's current state."""
|
||||
if self.active:
|
||||
if self.state == PeriodStates.READY: return 'No voting or submissions quite yet.'
|
||||
elif self.state == PeriodStates.SUBMISSIONS: return 'Submissions open; upload now.'
|
||||
elif self.state == PeriodStates.PAUSED: return 'Submissions closed. No voting *yet*.'
|
||||
elif self.state == PeriodStates.VOTING: return 'Vote on submissions now.'
|
||||
elif self.state == PeriodStates.FINISHED: return 'Voting closed. Contest results available.'
|
||||
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.'
|
||||
return "Error."
|
||||
|
||||
def __repr__(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user