FridayNightFunkinBoyfriendBot/commands/time.js

40 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-12-17 14:55:27 -05:00
const CommandError = require('../CommandModules/command_error')
module.exports = {
name: 'time',
description:['check the time'],
aliases:['clock', 'timezone'],
2023-12-20 11:54:03 -05:00
trustLevel: 0,
async execute (context) {
2023-12-17 14:55:27 -05:00
const bot = context.bot
const message = context.arguments.join(' ')
const moment = require('moment-timezone')
const source = context.source
const args = context.arguments
const timezone = args.join(' ')
2024-01-27 10:07:18 -05:00
if (!moment.tz.names().map((zone) => zone.toLowerCase()).includes(timezone.toLowerCase()) && bot.options.Core.CorelessMode) {
bot.chat('Invalid timezone')
2024-01-27 10:07:18 -05:00
}else{
throw new CommandError('Invalid timezone')
2023-12-17 14:55:27 -05:00
}
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' }]
2024-01-27 10:07:18 -05:00
if (bot.options.Core.CorelessMode) {
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
bot.chat(`The current time and date for the timezone &b${timezone}`)
await sleep(1000)
bot.chat(`is:`)
await sleep(1000)
bot.chat(`&a${momented}`)
}else{
2023-12-17 14:55:27 -05:00
source.sendFeedback(component)
}
}
}