def _time(self, ctx):
"""Determine the current time in a timezone specified.
The timezone is case sensitive as seen in [this list](https://pastebin.com/B5tLQdEY).
**Usage:** `g_time <timezone>
**Permission:** User"""
umsg = ctx.message.content
args = umsg.split(' ')
if len(args) > 1:
try:
if args[1].startswith('GMT'):
if args[1].startswith('GMT+'):
t = args[1].replace('+', '-')
elif args[1].startswith('GMT-'):
t = args[1].replace('-', '+')
tz = pytz.timezone('Etc/'+t)
else:
tz = pytz.timezone(args[1])
await ctx.send("The time in **{0}** is {1}".format(args[1], datetime.datetime.now(tz).strftime("`%H:%M:%S` on `%d-%b-%Y`")))
except pytz.UnknownTimeZoneError:
await ctx.send('Couldn\'t find that timezone, make sure to use one from this list: <https://pastebin.com/B5tLQdEY>\nAlso remember that timezones are case sensitive.')
else:
await ctx.send(":x: Usage: `{}time <timezone>`".format(self.bot.command_prefix[0]))
评论列表
文章目录