calendar command qol

This commit is contained in:
esef committed 2026-07-13 00:32:01 +03:00
1 parent 61de4c3933
commit f8c7fc4fc6
2 files changed
+14 -5

No files matched your search

+2 -2
View File
@@ -19,7 +19,7 @@ FIRESTORE_CALENDAR = (
DATE_RE = re.compile(r"^\d{4}-\d{2}-\d{2}$") DATE_RE = re.compile(r"^\d{4}-\d{2}-\d{2}$")
TIME_RE = re.compile(r"^\d{2}:\d{2}$") TIME_RE = re.compile(r"^\d{2}:\d{2}$")
from .calendar_data import COUNTRY_TZ, tz_choices from .calendar_data import COUNTRY_TZ, country_autocomplete
class Calendar(commands.Cog): class Calendar(commands.Cog):
@@ -43,7 +43,7 @@ class Calendar(commands.Cog):
title="Event title", title="Event title",
description="Extra notes (optional)", description="Extra notes (optional)",
) )
@app_commands.choices(country=tz_choices()) @app_commands.autocomplete(country=country_autocomplete)
async def book_cmd( async def book_cmd(
self, self,
interaction: discord.Interaction, interaction: discord.Interaction,
+12 -3
View File
@@ -48,7 +48,16 @@ COUNTRY_TZ: dict[str, float] = {
# fmt: on # fmt: on
def tz_choices() -> list: async def country_autocomplete(
"""Return app_commands.Choice list for the country dropdown.""" _interaction,
current: str,
) -> list:
"""Return matching countries for slash-command autocomplete."""
from discord import app_commands from discord import app_commands
return [app_commands.Choice(name=c, value=c) for c in sorted(COUNTRY_TZ)] current = current.lower()
matches = [
app_commands.Choice(name=c, value=c)
for c in sorted(COUNTRY_TZ)
if current in c.lower()
]
return matches[:25] # Discord limits to 25 suggestions