mirror of
https://gitlab.com/pancakes1234/wdiscordbotserver.git
synced 2025-06-15 23:04:20 -06:00
Edit world_time.py
This commit is contained in:
parent
6384a67f20
commit
c889e9be0f
@ -9,13 +9,12 @@ class WorldTime(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@app_commands.command(name="worldtime", description="Display time in different timezones")
|
||||
@app_commands.command(name="world_time", description="Display timezones")
|
||||
@app_commands.describe(timezone="The timezone to display (optional)")
|
||||
async def worldtime(self, interaction: discord.Interaction, timezone: str = None):
|
||||
now = datetime.datetime.now(datetime.timezone.utc)
|
||||
|
||||
if timezone:
|
||||
# User specified a timezone
|
||||
try:
|
||||
tz = pytz.timezone(timezone)
|
||||
local_time = now.astimezone(tz)
|
||||
@ -24,12 +23,12 @@ class WorldTime(commands.Cog):
|
||||
# Handle invalid timezone
|
||||
await interaction.response.send_message(f"Unknown timezone: `{timezone}`\nTry using a timezone from the IANA Time Zone Database (e.g., 'America/New_York', 'Europe/London')", ephemeral=True)
|
||||
else:
|
||||
# No timezone specified, show 5 random timezones
|
||||
# no selected zone so displays fuckass zones :3
|
||||
all_timezones = list(pytz.all_timezones)
|
||||
random_timezones = random.sample(all_timezones, 5)
|
||||
|
||||
embed = discord.Embed(title="World Time", color=discord.Color.blue())
|
||||
embed.description = "Here are 5 random timezones:"
|
||||
embed.description = "Timezones"
|
||||
|
||||
for tz_name in random_timezones:
|
||||
tz = pytz.timezone(tz_name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user