Skip to content

Commit

Permalink
Fix choices with autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Sep 18, 2024
1 parent 2c55752 commit e705ece
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions worldtimezone/extensions/world_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import hikari
import lightbulb
import pytz

from extensions import world_clock_data

plugin = lightbulb.Plugin("WorldClock")
Expand Down Expand Up @@ -39,7 +38,9 @@ async def setIt_autocomplete_timezone(opt, inter):
@lightbulb.command("timezone", description="List common timezones")
@lightbulb.implements(lightbulb.SlashCommand)
async def timezoneIt(ctx: lightbulb.SlashContext) -> None:
ctx.respond(f"{world_clock_data.COMMON_TIMEZONES}\nFor all timezones: <https://github.com/stub42/pytz/blob/master/tz/zone.tab>")
ctx.respond(
f"{world_clock_data.COMMON_TIMEZONES}\nFor all timezones: <https://github.com/stub42/pytz/blob/master/tz/zone.tab>"
)


@lightbulb.add_checks(lightbulb.human_only)
Expand Down Expand Up @@ -114,7 +115,7 @@ def add_field(u, tz):
"timezone of the time|date (default is yours)",
type=str,
required=False,
choices=world_clock_data.COMMON_TIMEZONES,
autocomplete=True,
)
@lightbulb.command(
"convert",
Expand Down Expand Up @@ -156,6 +157,11 @@ async def convertIt(
await ctx.respond(message)


@convertIt.autocomplete("timezone")
async def convertIt_autocomplete_timezone(opt, inter):
return world_clock_data.COMMON_TIMEZONES


@lightbulb.add_checks(lightbulb.human_only)
@plugin.command
@lightbulb.add_cooldown(10, 1, lightbulb.GuildBucket)
Expand Down

0 comments on commit e705ece

Please sign in to comment.