diff --git a/package.json b/package.json index dc2afb13..c575a671 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,8 @@ "valid-url": "^1.0.9", "wavefile": "^11.0.0", "winston": "^3.3.3", - "ytdl-core": "^4.5.0" + "ytdl-core": "^4.5.0", + "zip-to-timezone": "^1.1.5" }, "optionalDependencies": { "bufferutil": "^4.0.3", diff --git a/types/timezone.js b/types/timezone.js index 55792b3a..82b7299c 100644 --- a/types/timezone.js +++ b/types/timezone.js @@ -1,5 +1,6 @@ const { ArgumentType } = require('discord.js-commando'); const cityTimezones = require('city-timezones'); +const { ZipToTz } = require('zip-to-timezone'); const moment = require('moment-timezone'); module.exports = class TimezoneType extends ArgumentType { @@ -11,10 +12,15 @@ module.exports = class TimezoneType extends ArgumentType { value = value.replaceAll(' ', '_').toLowerCase(); const directZone = moment.tz.zone(value); if (directZone) return true; - const cityZone = cityTimezones.lookupViaCity(value); - if (cityZone.length) return true; - const provZone = cityTimezones.findFromCityStateProvince(value); - if (provZone.length) return true; + try { + const zipZone = new ZipToTz().full(value); + return zipZone; + } catch { + const cityZone = cityTimezones.lookupViaCity(value); + if (cityZone.length) return true; + const provZone = cityTimezones.findFromCityStateProvince(value); + if (provZone.length) return true; + } return false; }