34 lines
898 B
Python
34 lines
898 B
Python
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
|