diff --git a/commands/events/time.js b/commands/events/time.js new file mode 100644 index 00000000..5f0b83c6 --- /dev/null +++ b/commands/events/time.js @@ -0,0 +1,33 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class TimeCommand extends Command { + constructor(client) { + super(client, { + name: 'time', + aliases: ['time-zone'], + group: 'events', + memberName: 'time', + description: 'Responds with the current time in a particular location.', + details: '**Zones**: ', + args: [ + { + key: 'timeZone', + label: 'time zone', + prompt: 'Which time zone do you want to get the time of?', + type: 'string', + parse: timeZone => timeZone.replace(/ /g, '_').toUpperCase() + } + ] + }); + } + + run(msg, { timeZone }) { + if (timeZone === 'NEOPIA/STANDARD') timeZone = 'AMERICA/VANCOUVER'; + try { + const time = new Date().toLocaleTimeString('en-US', { timeZone }); + return msg.say(`The current time in ${timeZone} is ${time}.`); + } catch (err) { + return msg.reply('Invalid time zone. Refer to .'); + } + } +}; diff --git a/package.json b/package.json index e0a785fd..82cd5e40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "56.3.1", + "version": "56.4.0", "description": "Your personal server companion.", "main": "XiaoBot.js", "scripts": {