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(