Add check for time

This commit is contained in:
Dragon Fire
2025-05-30 21:58:31 -04:00
parent 6f694330c5
commit 505c28ad21
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -36,10 +36,11 @@ module.exports = class TimeCommand extends Command {
run(msg, { timeZone }) {
const time = moment().tz(timeZone).format('h:mm A');
const location = timeZone.split('/');
const word = location === 'lily' ? 'for' : 'is';
const main = firstUpperCase(location[0], /[_ ]/);
const sub = location[1] ? firstUpperCase(location[1], /[_ ]/) : null;
const subMain = location[2] ? firstUpperCase(location[2], /[_ ]/) : null;
const parens = sub ? ` (${subMain ? `${sub}, ` : ''}${main})` : '';
return msg.say(`The current time in ${subMain || sub || main}${parens} is ${time}.`);
return msg.say(`The current time ${word} ${subMain || sub || main}${parens} is ${time}.`);
}
};