mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-12-18 03:12:23 -05:00
26 lines
1,003 B
JavaScript
26 lines
1,003 B
JavaScript
|
/* eslint-disable max-len */
|
||
|
const moment = require('moment-timezone');
|
||
|
module.exports = {
|
||
|
name: 'time',
|
||
|
alias: [],
|
||
|
description: 'Shows the time',
|
||
|
usage: '<timezone>',
|
||
|
trusted: 0,
|
||
|
execute: function(bot, username, usernameraw, sender, prefix, args) {
|
||
|
const timezone = args.join(' ');
|
||
|
const momented = moment().tz(`${timezone}`).format('dddd, MMMM Do, YYYY, h:mm:ss A');
|
||
|
const command = 'minecraft:tellraw @a ' + JSON.stringify(['', {text: 'The current date and time for the timezone ', color: 'white'}, {text: timezone, color: 'aqua'}, {text: ' is: ', color: 'white'}, {text: `${momented}`, color: 'green'}]);
|
||
|
if (timezone.toLowerCase()==='asia/bangkok') {
|
||
|
bot.core.run(command);
|
||
|
return;
|
||
|
} else if (timezone.toLowerCase()==='utc') {
|
||
|
bot.core.run(command);
|
||
|
return;
|
||
|
} else if (momented===moment().format('dddd, MMMM Do, YYYY, h:mm:ss A')) {
|
||
|
throw new SyntaxError('Invalid timezone');
|
||
|
} else {
|
||
|
bot.core.run(command);
|
||
|
}
|
||
|
},
|
||
|
};
|