Skip to main content

World Clock

This command shows the current time in various cities around the world.

Trigger

Type: Command
Trigger: worldclock

Usage

  • -worldclock - Shows the current time in various cities around the world.

Changing the cities used

To change the cities displayed, just modify the $clocks variable. The key is the city name and the value is its timezone database name.

tip

To get the latter value, you can use this tool to find it (select the Area/City option).

Code

{{/*
Simple world clock.
See <https://yagpdb-cc.github.io/utilities/world-clock> for more information.

Author: jo3-l <https://github.com/jo3-l>
*/}}

{{ $clocks := sdict
"Vancouver" "America/Vancouver"
"New York" "America/New_York"
"London" "Europe/London"
"Moscow" "Europe/Moscow"
"Tokyo" "Asia/Tokyo"
}}

{{ $embed := sdict
"title" "🕰️ World Clock"
"fields" cslice
"color" 0x0070BB
"footer" (sdict "text" "Your time")
"timestamp" currentTime
}}

{{ range $name, $ := $clocks }}
{{- $time := currentTime.In (newDate 0 0 0 0 0 0 .).Location }}
{{- $formatted := printf "%s, %s"
$time.Weekday.String
($time.Format "3:04:05 PM")
}}
{{- $embed.fields.Append (sdict
"name" $name
"value" $formatted
) | $embed.Set "fields" -}}
{{ end }}

{{ sendMessage nil (cembed $embed) }}

Author

This custom command was written by @jo3-l.