Improved some messages and prepared them for i18n
This commit is contained in:
33
modules/utils/validation_utils.py
Normal file
33
modules/utils/validation_utils.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from discord import ApplicationContext
|
||||
|
||||
|
||||
async def is_operation_confirmed(ctx: ApplicationContext, confirm: bool) -> bool:
|
||||
if confirm is None or not confirm:
|
||||
await ctx.respond(ctx.bot._("operation_unconfirmed", "messages", locale=ctx.locale))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def is_event_status_valid(
|
||||
ctx: ApplicationContext,
|
||||
event: "PycordEvent",
|
||||
) -> bool:
|
||||
if event.is_cancelled:
|
||||
# TODO Make a nice message
|
||||
await ctx.respond("This event was cancelled.")
|
||||
return False
|
||||
|
||||
if (
|
||||
event.starts.replace(tzinfo=ZoneInfo("UTC"))
|
||||
<= datetime.now(tz=ZoneInfo("UTC"))
|
||||
<= event.ends.replace(tzinfo=ZoneInfo("UTC"))
|
||||
):
|
||||
# TODO Make a nice message
|
||||
await ctx.respond("Ongoing events cannot be modified.")
|
||||
return False
|
||||
|
||||
return True
|
Reference in New Issue
Block a user