diff --git a/cogs/cog_event.py b/cogs/cog_event.py index fb23875..e8641ed 100644 --- a/cogs/cog_event.py +++ b/cogs/cog_event.py @@ -24,7 +24,6 @@ from modules.utils import ( ) -# noinspection Mypy class CogEvent(Cog): """Cog with event management commands.""" @@ -98,10 +97,7 @@ class CogEvent(Cog): start_date: datetime = datetime.strptime(start, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone) end_date: datetime = datetime.strptime(end, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone) except ValueError: - # TODO Introduce i18n - await ctx.respond( - "Could not parse start and end dates. Please, make sure these are provided in `DD.MM.YYYY HH:MM` format." - ) + await ctx.respond(self.bot._("event_dates_parsing_failed", "messages", locale=ctx.locale)) return if not await validate_event_validity(ctx, name, start_date, end_date, to_utc=True): @@ -120,9 +116,10 @@ class CogEvent(Cog): thumbnail=processed_media[0] if thumbnail else None, ) - # TODO Introduce i18n await ctx.respond( - f"Event **{event.name}** has been created and will take place ." + self.bot._("event_created", "messages", locale=ctx.locale).format( + event_name=event.name, start_time=get_unix_timestamp(event.starts, to_utc=True) + ) ) @command_group.command( @@ -205,10 +202,7 @@ class CogEvent(Cog): else datetime.strptime(start, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone) ) except ValueError: - # TODO Make a nice message - await ctx.respond( - "Could not parse the start date. Please, make sure it is provided in `DD.MM.YYYY HH:MM` format." - ) + await ctx.respond(self.bot._("event_start_date_parsing_failed", "messages", locale=ctx.locale)) return try: @@ -218,10 +212,7 @@ class CogEvent(Cog): else datetime.strptime(end, "%d.%m.%Y %H:%M").replace(tzinfo=guild_timezone) ) except ValueError: - # TODO Make a nice message - await ctx.respond( - "Could not parse the end date. Please, make sure it is provided in `DD.MM.YYYY HH:MM` format." - ) + await ctx.respond(self.bot._("event_end_date_parsing_failed", "messages", locale=ctx.locale)) return if not await validate_event_validity( @@ -248,9 +239,11 @@ class CogEvent(Cog): # TODO Notify participants about time changes - # TODO Make a nice message await ctx.respond( - f"Event **{pycord_event.name}** has been updated and will take place ." + self.bot._("event_updated", "messages", locale=ctx.locale).format( + event_name=pycord_event.name, + start_time=get_unix_timestamp(pycord_event.starts, to_utc=True), + ) ) @command_group.command( @@ -309,16 +302,22 @@ class CogEvent(Cog): or end_date <= datetime.now(tz=ZoneInfo("UTC")) or start_date <= datetime.now(tz=ZoneInfo("UTC")) ): - # TODO Make a nice message - await ctx.respond("Finished or ongoing events cannot be cancelled.") + await ctx.respond( + self.bot._("event_not_editable", "messages", locale=ctx.locale).format( + event_name=pycord_event.name + ) + ) return await pycord_event.cancel() # TODO Notify participants about cancellation - # TODO Make a nice message - await ctx.respond(f"Event **{pycord_event.name}** was cancelled.") + await ctx.respond( + self.bot._("event_cancelled", "messages", locale=ctx.locale).format( + event_name=pycord_event.name + ) + ) @command_group.command( name="show", @@ -346,16 +345,20 @@ class CogEvent(Cog): stages: List[PycordEventStage] = await self.bot.get_event_stages(pycord_event) - # TODO Make a nice message stages_string: str = "\n\n".join( - f"**Stage {stage.sequence+1}**\nAnswer: ||{stage.answer}||" for stage in stages + self.bot._("stage_entry", "messages", locale=ctx.locale).format( + sequence=stage.sequence + 1, answer=stage.answer + ) + for stage in stages ) # TODO Show users registered for the event - # TODO Introduce i18n - event_info_string: str = ( - f"**Event details**\n\nName: {pycord_event.name}\nStarts: \nEnds: \n\nStages:\n{stages_string}" + event_info_string: str = self.bot._("event_details", "messages", locale=ctx.locale).format( + event_name=pycord_event.name, + start_time=get_unix_timestamp(starts_date), + end_time=get_unix_timestamp(ends_date), + stages=stages_string, ) chunk_size: int = 2000 diff --git a/locale/en-US.json b/locale/en-US.json index c5e2363..7c84b59 100644 --- a/locale/en-US.json +++ b/locale/en-US.json @@ -1,13 +1,21 @@ { "messages": { "admin_user_channel_creation_failed": "Event channel could not be created for user **{display_name}** ({mention}) and event **{event_name}**.", + "admin_user_channel_fixed": "Fixed event channel of user **{display_name}** ({mention}) for the event **{event_name}**.", "admin_user_completed_event": "User **{display_name}** ({mention}) has completed the event **{event_name}**", "admin_user_completed_stage": "User **{display_name}** ({mention}) has completed the stage {stage_sequence} of the event **{event_name}**.", - "admin_user_channel_fixed": "Fixed event channel of user **{display_name}** ({mention}) for the event **{event_name}**.", "config_reset": "Configuration has been reset. You can update it using `/config set`, otherwise no events can be held.", "config_set": "Configuration has been updated. You can review it anytime using `/config show`.", "config_show": "**Guild config**\n\nChannel: <#{channel_id}>\nCategory: <#{category_id}>\nTimezone: `{timezone}`", + "event_cancelled": "Event **{event_name}** was cancelled.", + "event_created": "Event **{event_name}** has been created and will take place .", + "event_dates_parsing_failed": "Could not parse start and end dates. Please, make sure these are provided in `DD.MM.YYYY HH:MM` format.", + "event_details": "**Event details**\n\nName: {event_name}\nStarts: \nEnds: \n\nStages:\n{stages}", + "event_end_date_parsing_failed": "Could not parse the end date. Please, make sure it is provided in `DD.MM.YYYY HH:MM` format.", + "event_not_editable": "Finished or ongoing events cannot be cancelled.", "event_not_found": "Event was not found.", + "event_start_date_parsing_failed": "Could not parse the start date. Please, make sure it is provided in `DD.MM.YYYY HH:MM` format.", + "event_updated": "Event **{event_name}** has been updated and will take place .", "guess_completed_event": "Congratulations! You have completed the event!", "guess_incorrect_channel": "Usage outside own event channel is not allowed.", "guess_incorrect_event": "Your event could not be found. Please, contact the administrator.", @@ -20,17 +28,18 @@ "register_already_registered": "You are already registered for this event.", "register_success_ongoing": "You are now registered for the event **{event_name}**.\n\nNew channel has been created for you and further instructions will are provided in it. Good luck!", "register_success_scheduled": "You are now registered for the event **{event_name}**.\n\nNew channel will be created for you and further instructions will be provided as soon as the event starts . Good luck!", + "stage_entry": "**Stage {sequence}**\nAnswer: ||{answer}||", "status": "**QuizBot** v{version}\n\nUptime: since ", "status_git": "**QuizBot** v{version} (`{commit}`)\n\nUptime: up since ", "timezone_invalid": "Timezone **{timezone}** was not found. Please, select one of the timezones provided by the autocompletion.", "unexpected_error": "An unexpected error has occurred. Please, contact the administrator.", "unregister_not_registered": "You are not registered for this event.", "unregister_unregistered": "You are no longer registered for this event.", + "user_channels_updated": "Event channels of the user **{display_name}** were updated.", "user_jail_already_jailed": "User **{display_name}** is already jailed.", "user_jail_successful": "User **{display_name}** has been jailed and cannot interact with events anymore.", "user_unjail_not_jailed": "User **{display_name}** is not jailed.", - "user_unjail_successful": "User **{display_name}** has been unjailed and can interact with events again.", - "user_channels_updated": "Event channels of the user **{display_name}** were updated." + "user_unjail_successful": "User **{display_name}** has been unjailed and can interact with events again." }, "commands": { "config": {