Introduced i18n for "/user update_channels"

This commit is contained in:
2025-05-02 14:18:58 +02:00
parent 3dcae36dec
commit fa200ef92d
2 changed files with 54 additions and 21 deletions

View File

@@ -1,4 +1,5 @@
from datetime import datetime
from logging import Logger
from pathlib import Path
from typing import List, Dict, Any
from zoneinfo import ZoneInfo
@@ -20,7 +21,9 @@ from classes import PycordUser, PycordEvent, PycordGuild
from classes.errors import GuildNotFoundError
from classes.pycord_bot import PycordBot
from modules.database import col_users
from modules.utils import is_operation_confirmed
from modules.utils import is_operation_confirmed, get_logger
logger: Logger = get_logger(__name__)
class CogUser(Cog):
@@ -35,26 +38,17 @@ class CogUser(Cog):
description_localizations=in_every_locale("description", "commands", "user"),
)
# TODO Implement the command
# @command_group.command(
# name="create_channel",
# description="Create channel for the user",
# )
# @option(
# "user",
# description="Selected user",
# )
# async def command_user_create_channel(self, ctx: ApplicationContext, user: User) -> None:
# await ctx.respond("Not implemented.")
# TODO Implement the command
@command_group.command(
name="update_channels",
description="Update user's event channels",
description=_("description", "commands", "user_update_channels"),
description_localizations=in_every_locale("description", "commands", "user_update_channels"),
)
@option(
"user",
description="Selected user",
description=_("description", "commands", "user_update_channels", "options", "user"),
description_localizations=in_every_locale(
"description", "commands", "user_update_channels", "options", "user"
),
)
async def command_user_update_channels(self, ctx: ApplicationContext, user: User) -> None:
try:
@@ -101,6 +95,23 @@ class CogUser(Cog):
self.bot, ctx.guild, guild, event, cache=self.bot.cache
)
try:
await self.bot.notify_admins(
ctx.guild,
guild,
self.bot._("admin_user_channel_fixed", "messages", locale=ctx.locale).format(
display_name=user.display_name, mention=user.mention, event_name=event.name
),
)
except Exception as exc:
logger.error(
"Could not notify admins that user %s got their event channel for %s fixed due to: %s",
user.id,
event._id,
exc,
exc_info=exc,
)
if channel is None:
continue
@@ -123,7 +134,23 @@ class CogUser(Cog):
await self.bot.send_stage_question(channel, event, await self.bot.find_event_stage(stage_id))
await ctx.respond("Channels were updated.")
await ctx.respond(
self.bot._("user_channels_updated", "messages", locale=ctx.locale).format(
display_name=user.display_name
)
)
# TODO Implement the command
# @command_group.command(
# name="create_channel",
# description="Create channel for the user",
# )
# @option(
# "user",
# description="Selected user",
# )
# async def command_user_create_channel(self, ctx: ApplicationContext, user: User) -> None:
# await ctx.respond("Not implemented.")
# TODO Implement the command
# @command_group.command(

View File

@@ -3,6 +3,7 @@
"admin_user_channel_creation_failed": "Event channel could not be created for user **{display_name}** ({mention}) and 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}`",
@@ -28,7 +29,8 @@
"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_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."
},
"commands": {
"config": {
@@ -215,9 +217,13 @@
"description": "Create channel for the user",
"options": {}
},
"user_update_channel": {
"description": "Update user's channel",
"options": {}
"user_update_channels": {
"description": "Update user's event channels",
"options": {
"user": {
"description": "Selected user"
}
}
},
"user_delete_channel": {
"description": "Delete user's channel",