2020-08-19 00:19:12 +03:00
|
|
|
import { timeAndDateCmd } from "../types";
|
|
|
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
2020-08-19 00:47:31 +03:00
|
|
|
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
|
|
|
import { isValidTimezone } from "../../../utils/isValidTimezone";
|
|
|
|
import { disableInlineCode, trimLines } from "../../../utils";
|
|
|
|
import { parseFuzzyTimezone } from "../../../utils/parseFuzzyTimezone";
|
2020-08-19 00:19:12 +03:00
|
|
|
|
|
|
|
export const SetTimezoneCmd = timeAndDateCmd({
|
|
|
|
trigger: "timezone",
|
|
|
|
permission: "can_set_timezone",
|
|
|
|
|
|
|
|
signature: {
|
2020-08-19 00:47:31 +03:00
|
|
|
timezone: ct.string(),
|
2020-08-19 00:19:12 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
async run({ pluginData, message, args }) {
|
2020-08-19 00:47:31 +03:00
|
|
|
const parsedTz = parseFuzzyTimezone(args.timezone);
|
|
|
|
if (!parsedTz) {
|
|
|
|
sendErrorMessage(
|
|
|
|
pluginData,
|
|
|
|
message.channel,
|
|
|
|
trimLines(`
|
|
|
|
Invalid timezone: \`${disableInlineCode(args.timezone)}\`
|
|
|
|
Zeppelin uses timezone locations rather than specific timezone names.
|
|
|
|
See the **TZ database name** column at <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> for a list of valid options.
|
|
|
|
`),
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
await pluginData.state.memberTimezones.set(message.author.id, parsedTz);
|
|
|
|
sendSuccessMessage(pluginData, message.channel, `Your timezone is now set to **${parsedTz}**`);
|
2020-08-19 00:19:12 +03:00
|
|
|
},
|
|
|
|
});
|