mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-12-17 19:02:22 -05:00
44 lines
1.9 KiB
JavaScript
44 lines
1.9 KiB
JavaScript
/* eslint-disable max-len */
|
|
const {MessageEmbed} = require('discord.js');
|
|
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, hh:mm:ss A');
|
|
const component = [{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' || timezone.toLowerCase() === 'utc') {
|
|
bot.tellraw('@a', component);
|
|
return;
|
|
} else if (momented === moment().format('dddd, MMMM Do, YYYY, hh:mm:ss A')) {
|
|
throw new SyntaxError('Invalid timezone');
|
|
} else {
|
|
bot.tellraw('@a', component);
|
|
}
|
|
},
|
|
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
|
const timezone = args.join(' ');
|
|
const momented = moment().tz(`${timezone}`).format('dddd, MMMM Do, YYYY, hh:mm:ss A');
|
|
const description = `The current date and time for the timezone ${timezone} is: ${momented}`;
|
|
if (timezone.toLowerCase() === 'asia/bangkok' || timezone.toLowerCase() === 'utc') {
|
|
const Embed = new MessageEmbed()
|
|
.setColor('#FFFF00')
|
|
.setTitle('Time')
|
|
.setDescription(description);
|
|
channeldc.send({embeds: [Embed]});
|
|
return;
|
|
} else if (momented === moment().format('dddd, MMMM Do, YYYY, hh:mm:ss A')) {
|
|
throw new SyntaxError('Invalid timezone');
|
|
} else {
|
|
const Embed = new MessageEmbed()
|
|
.setColor('#FFFF00')
|
|
.setTitle('Time')
|
|
.setDescription(description);
|
|
channeldc.send({embeds: [Embed]});
|
|
}
|
|
},
|
|
};
|