Fixed i18n for PycordBot
This commit is contained in:
@@ -97,13 +97,12 @@ class PycordBot(LibPycordBot):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if len(event.stage_ids) == 0:
|
if len(event.stage_ids) == 0:
|
||||||
# TODO Make a nice message for management
|
|
||||||
logger.error("Could not start the event %s: no event stages are defined.", event._id)
|
logger.error("Could not start the event %s: no event stages are defined.", event._id)
|
||||||
|
|
||||||
await self.notify_admins(
|
await self.notify_admins(
|
||||||
guild,
|
guild,
|
||||||
pycord_guild,
|
pycord_guild,
|
||||||
f"Could not start the event **{event.name}**: no event stages are defined.",
|
self.bot._("admin_event_no_stages_defined", "messages").format(event_name=event.name),
|
||||||
)
|
)
|
||||||
|
|
||||||
await event.cancel(self.cache)
|
await event.cancel(self.cache)
|
||||||
@@ -134,7 +133,9 @@ class PycordBot(LibPycordBot):
|
|||||||
await self.notify_admins(
|
await self.notify_admins(
|
||||||
guild,
|
guild,
|
||||||
pycord_guild,
|
pycord_guild,
|
||||||
f"Event channel could not be created for user with ID `{user.id}` (<@{user.id}>) and event **{event.name}**: user was not found on the server.",
|
self.bot._("admin_channel_creation_failed_no_user", "messages").format(
|
||||||
|
user_id=user.id, event_name=event.name
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
@@ -152,7 +153,11 @@ class PycordBot(LibPycordBot):
|
|||||||
await self.notify_admins(
|
await self.notify_admins(
|
||||||
guild,
|
guild,
|
||||||
pycord_guild,
|
pycord_guild,
|
||||||
f"Event channel could not be created for user **{discord_user.display_name}** ({discord_user.mention}) and event **{event.name}**.",
|
self.bot._("admin_channel_creation_failed", "messages").format(
|
||||||
|
display_name=discord_user.display_name,
|
||||||
|
mention=discord_user.mention,
|
||||||
|
event_name=event.name,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
@@ -163,10 +168,8 @@ class PycordBot(LibPycordBot):
|
|||||||
else File(Path(f"data/{event.thumbnail['id']}"), event.thumbnail["filename"])
|
else File(Path(f"data/{event.thumbnail['id']}"), event.thumbnail["filename"])
|
||||||
)
|
)
|
||||||
|
|
||||||
# Send a notification about event start
|
|
||||||
# TODO Make a nice message
|
|
||||||
await user_channel.send(
|
await user_channel.send(
|
||||||
f"Event **{event.name}** is starting!\n\nUse slash command `/guess` to suggest your answers to each event stage.",
|
self.bot._("event_is_starting", "messages").format(event_name=event.name),
|
||||||
file=thumbnail,
|
file=thumbnail,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -180,11 +183,10 @@ class PycordBot(LibPycordBot):
|
|||||||
chunk, files=None if index != question_chunks_length - 1 else first_stage_files
|
chunk, files=None if index != question_chunks_length - 1 else first_stage_files
|
||||||
)
|
)
|
||||||
|
|
||||||
# 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.",
|
self.bot._("admin_event_started", "messages").format(event_name=event.name),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _process_events_end(self) -> None:
|
async def _process_events_end(self) -> None:
|
||||||
@@ -218,9 +220,11 @@ class PycordBot(LibPycordBot):
|
|||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# TODO Make a nice message
|
|
||||||
stages_string: str = "\n\n".join(
|
stages_string: str = "\n\n".join(
|
||||||
f"**Stage {stage.sequence+1}**\nAnswer: ||{stage.answer}||" for stage in stages
|
self.bot._("stage_entry", "messages").format(
|
||||||
|
sequence=stage.sequence + 1, answer=stage.answer
|
||||||
|
)
|
||||||
|
for stage in stages
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get list of participants
|
# Get list of participants
|
||||||
@@ -238,9 +242,8 @@ class PycordBot(LibPycordBot):
|
|||||||
# Send a notification about event start
|
# Send a notification about event start
|
||||||
user_channel: TextChannel = guild.get_channel(user.event_channels[str(event._id)])
|
user_channel: TextChannel = guild.get_channel(user.event_channels[str(event._id)])
|
||||||
|
|
||||||
# TODO Make a nice message
|
event_ended_string: str = self.bot._("event_ended", "messages").format(
|
||||||
event_ended_string: str = (
|
event_name=event.name, stages=stages_string
|
||||||
f"Event **{event.name}** has ended! Stages and respective answers are listed below.\n\n{stages_string}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
chunk_size: int = 2000
|
chunk_size: int = 2000
|
||||||
@@ -256,11 +259,10 @@ class PycordBot(LibPycordBot):
|
|||||||
# Lock each participant out
|
# Lock each participant out
|
||||||
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
|
|
||||||
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.",
|
self.bot._("admin_event_ended", "messages").format(event_name=event.name),
|
||||||
)
|
)
|
||||||
|
|
||||||
await event.end(cache=self.cache)
|
await event.end(cache=self.cache)
|
||||||
|
@@ -1,5 +1,10 @@
|
|||||||
{
|
{
|
||||||
"messages": {
|
"messages": {
|
||||||
|
"admin_channel_creation_failed": "Event channel could not be created for user **{display_name}** ({mention}) and event **{event_name}**.",
|
||||||
|
"admin_channel_creation_failed_no_user": "Event channel could not be created for user with ID `{user_id}` (<@{user_id}>) and event **{event_name}**: user was not found on the server.",
|
||||||
|
"admin_event_ended": "Event **{event_name}** has ended! Users can no longer submit their answers.",
|
||||||
|
"admin_event_no_stages_defined": "Could not start the event **{event_name}**: no event stages are defined.",
|
||||||
|
"admin_event_started": "Event **{event_name}** has started! Users have gotten their channels and can already start submitting their answers.",
|
||||||
"admin_user_channel_creation_failed": "Event channel could not be created for user **{display_name}** ({mention}) and event **{event_name}**.",
|
"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_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_event": "User **{display_name}** ({mention}) has completed the event **{event_name}**",
|
||||||
@@ -14,7 +19,9 @@
|
|||||||
"event_end_before_start": "Start date must be before end date",
|
"event_end_before_start": "Start date must be before end date",
|
||||||
"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_end_date_parsing_failed": "Could not parse the end date. Please, make sure it is provided in `DD.MM.YYYY HH:MM` format.",
|
||||||
"event_end_past": "End date must not be in the past",
|
"event_end_past": "End date must not be in the past",
|
||||||
|
"event_ended": "Event **{event_name}** has ended! Stages and respective answers are listed below.\n\n{stages}",
|
||||||
"event_is_cancelled": "This event was cancelled.",
|
"event_is_cancelled": "This event was cancelled.",
|
||||||
|
"event_is_starting": "Event **{event_name}** is starting!\n\nUse slash command `/guess` to suggest your answers to each event stage.",
|
||||||
"event_name_duplicate": "There can only be one active event with the same name",
|
"event_name_duplicate": "There can only be one active event with the same name",
|
||||||
"event_not_editable": "Finished or ongoing events cannot be cancelled.",
|
"event_not_editable": "Finished or ongoing events cannot be cancelled.",
|
||||||
"event_not_found": "Event was not found.",
|
"event_not_found": "Event was not found.",
|
||||||
|
Reference in New Issue
Block a user