Made a couple of improvements to /guess
This commit is contained in:
@@ -110,7 +110,7 @@ class PycordBot(LibPycordBot):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# TODO Make a nice message
|
# TODO Make a nice message
|
||||||
await self._notify_admins(
|
await self.notify_admins(
|
||||||
guild,
|
guild,
|
||||||
pycord_guild,
|
pycord_guild,
|
||||||
f"Event **{event.name}** has started! Users have gotten their channels and can already start submitting their answers.",
|
f"Event **{event.name}** has started! Users have gotten their channels and can already start submitting their answers.",
|
||||||
@@ -150,7 +150,7 @@ class PycordBot(LibPycordBot):
|
|||||||
await user.lock_event_channel(guild, event._id, channel=user_channel)
|
await user.lock_event_channel(guild, event._id, channel=user_channel)
|
||||||
|
|
||||||
# TODO Make a nice message
|
# TODO Make a nice message
|
||||||
await self._notify_admins(
|
await self.notify_admins(
|
||||||
guild,
|
guild,
|
||||||
pycord_guild,
|
pycord_guild,
|
||||||
f"Event **{event.name}** has ended! Users can no longer submit their answers.",
|
f"Event **{event.name}** has ended! Users can no longer submit their answers.",
|
||||||
@@ -177,8 +177,9 @@ class PycordBot(LibPycordBot):
|
|||||||
async def _get_event_stages(self, event: PycordEvent) -> List[PycordEventStage]:
|
async def _get_event_stages(self, event: PycordEvent) -> List[PycordEventStage]:
|
||||||
return [(await self.find_event_stage(stage_id)) for stage_id in event.stage_ids]
|
return [(await self.find_event_stage(stage_id)) for stage_id in event.stage_ids]
|
||||||
|
|
||||||
|
# TODO Add documentation
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _notify_admins(guild: Guild, pycord_guild: PycordGuild, message: str) -> None:
|
async def notify_admins(guild: Guild, pycord_guild: PycordGuild, message: str) -> None:
|
||||||
management_channel: TextChannel | None = guild.get_channel(pycord_guild.channel_id)
|
management_channel: TextChannel | None = guild.get_channel(pycord_guild.channel_id)
|
||||||
|
|
||||||
if management_channel is None:
|
if management_channel is None:
|
||||||
|
@@ -45,6 +45,11 @@ class Guess(Cog):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if ctx.channel_id != user.event_channels[str(event._id)]:
|
||||||
|
# TODO Make a nice message
|
||||||
|
await ctx.respond("Usage outside own event channel is not allowed.", ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
if answer.lower() != stage.answer.lower():
|
if answer.lower() != stage.answer.lower():
|
||||||
# TODO Make a nice message
|
# TODO Make a nice message
|
||||||
# await ctx.respond("Provided answer is wrong.")
|
# await ctx.respond("Provided answer is wrong.")
|
||||||
@@ -67,7 +72,13 @@ class Guess(Cog):
|
|||||||
completed_event_ids=user.completed_event_ids,
|
completed_event_ids=user.completed_event_ids,
|
||||||
)
|
)
|
||||||
|
|
||||||
await ctx.respond("Event is completed.")
|
await ctx.respond("Congratulations! You have completed the event!")
|
||||||
|
|
||||||
|
await self.bot.notify_admins(
|
||||||
|
ctx.guild,
|
||||||
|
guild,
|
||||||
|
f"User **{ctx.author.display_name}** ({ctx.author.mention}) has completed the event",
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
next_stage: PycordEventStage = await self.bot.find_event_stage(next_stage_id)
|
next_stage: PycordEventStage = await self.bot.find_event_stage(next_stage_id)
|
||||||
@@ -81,6 +92,12 @@ class Guess(Cog):
|
|||||||
|
|
||||||
await user.set_event_stage(next_stage._id, cache=self.bot.cache)
|
await user.set_event_stage(next_stage._id, cache=self.bot.cache)
|
||||||
|
|
||||||
|
await self.bot.notify_admins(
|
||||||
|
ctx.guild,
|
||||||
|
guild,
|
||||||
|
f"User **{ctx.author.display_name}** ({ctx.author.mention}) has completed the stage {stage.sequence+1} of the event **{event.name}**.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot: PycordBot) -> None:
|
def setup(bot: PycordBot) -> None:
|
||||||
bot.add_cog(Guess(bot))
|
bot.add_cog(Guess(bot))
|
||||||
|
Reference in New Issue
Block a user