Introduced i18n to utility modules

This commit is contained in:
2025-05-03 00:45:22 +02:00
parent 34a506466d
commit aa2f90e1c5
3 changed files with 14 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ from bson import ObjectId
from discord import (
ApplicationContext,
)
from libbot.i18n import _
from modules.database import col_events
@@ -22,18 +23,15 @@ async def validate_event_validity(
end_date_internal: datetime = end_date.astimezone(ZoneInfo("UTC")) if to_utc else end_date
if start_date_internal < datetime.now(tz=ZoneInfo("UTC")):
# TODO Make a nice message
await ctx.respond("Start date must not be in the past")
await ctx.respond(_("event_start_past", "messages", locale=ctx.locale))
return False
if end_date_internal < datetime.now(tz=ZoneInfo("UTC")):
# TODO Make a nice message
await ctx.respond("End date must not be in the past")
await ctx.respond(_("event_end_past", "messages", locale=ctx.locale))
return False
if start_date_internal >= end_date_internal:
# TODO Make a nice message
await ctx.respond("Start date must be before end date")
await ctx.respond(_("event_end_before_start", "messages", locale=ctx.locale))
return False
# TODO Add validation for concurrent events.
@@ -49,8 +47,7 @@ async def validate_event_validity(
query["_id"] = {"$ne": event_id}
if (await col_events.find_one(query)) is not None:
# TODO Make a nice message
await ctx.respond("There can only be one active event with the same name")
await ctx.respond(_("event_name_duplicate", "messages", locale=ctx.locale))
return False
return True