This commit is contained in:
ChomeNS 2022-12-30 20:57:58 +07:00
parent 0e706e7251
commit 1d0d365eed

View file

@ -8,15 +8,11 @@ module.exports = {
trusted: 0,
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
const timezone = args.join(' ')
const format = 'dddd, MMMM Do, YYYY, hh:mm:ss A'
const momented = moment().tz(timezone).format(format)
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 (momented === moment().format(format) &&
(timezone.toLowerCase() !== 'asia/bangkok' ||
timezone.toLowerCase() !== 'utc' ||
timezone.toLowerCase() !== 'america/new_york'
)
) {
if (timezone.toLowerCase() === 'asia/bangkok' || timezone.toLowerCase() === 'utc' || timezone.toLowerCase() === 'america/new_york') {
bot.tellraw(selector, component)
} else if (momented === moment().format('dddd, MMMM Do, YYYY, hh:mm:ss A')) {
throw new SyntaxError('Invalid timezone')
} else {
bot.tellraw(selector, component)
@ -24,15 +20,15 @@ module.exports = {
},
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
const timezone = args.join(' ')
const format = 'dddd, MMMM Do, YYYY, hh:mm:ss A'
const momented = moment().tz(timezone).format(format)
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 (momented === moment().format(format) &&
(timezone.toLowerCase() !== 'asia/bangkok' ||
timezone.toLowerCase() !== 'utc' ||
timezone.toLowerCase() !== 'america/new_york'
)
) {
if (timezone.toLowerCase() === 'asia/bangkok' || timezone.toLowerCase() === 'utc' || timezone.toLowerCase() === 'america/new_york') {
const Embed = new EmbedBuilder()
.setColor(config.discord.embedsColors.normal)
.setTitle('Time')
.setDescription(description)
channeldc.send({ embeds: [Embed] })
} else if (momented === moment().format('dddd, MMMM Do, YYYY, hh:mm:ss A')) {
throw new SyntaxError('Invalid timezone')
} else {
const Embed = new EmbedBuilder()