diff --git a/classes/pycord_bot.py b/classes/pycord_bot.py index a4b6248..46c4b56 100644 --- a/classes/pycord_bot.py +++ b/classes/pycord_bot.py @@ -110,7 +110,7 @@ class PycordBot(LibPycordBot): ) # TODO Make a nice message - await self._notify_admins( + await self.notify_admins( guild, pycord_guild, 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) # TODO Make a nice message - await self._notify_admins( + await self.notify_admins( guild, pycord_guild, 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]: return [(await self.find_event_stage(stage_id)) for stage_id in event.stage_ids] + # TODO Add documentation @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) if management_channel is None: diff --git a/cogs/guess.py b/cogs/guess.py index c290d7b..fea3e55 100644 --- a/cogs/guess.py +++ b/cogs/guess.py @@ -45,6 +45,11 @@ class Guess(Cog): ) 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(): # TODO Make a nice message # await ctx.respond("Provided answer is wrong.") @@ -67,7 +72,13 @@ class Guess(Cog): 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 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 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: bot.add_cog(Guess(bot))