3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Add support for server-specific timezone and date format settings

This commit is contained in:
Dragory 2020-08-10 00:24:06 +03:00
parent ddbbc543c2
commit c67a1df11d
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
51 changed files with 326 additions and 168 deletions

View file

@ -3,6 +3,8 @@ import { sendErrorMessage } from "src/pluginUtils";
import { createChunkedMessage, sorter } from "src/utils";
import moment from "moment-timezone";
import humanizeDuration from "humanize-duration";
import { inGuildTz } from "../../../utils/timezones";
import { DBDateFormat, getDateFormat } from "../../../utils/dateFormats";
export const RemindersCmd = remindersCommand({
trigger: "reminders",
@ -20,10 +22,13 @@ export const RemindersCmd = remindersCommand({
const lines = Array.from(reminders.entries()).map(([i, reminder]) => {
const num = i + 1;
const paddedNum = num.toString().padStart(longestNum, " ");
const target = moment(reminder.remind_at, "YYYY-MM-DD HH:mm:ss");
const diff = target.diff(moment());
const target = moment.utc(reminder.remind_at, "YYYY-MM-DD HH:mm:ss");
const diff = target.diff(moment.utc());
const result = humanizeDuration(diff, { largest: 2, round: true });
return `\`${paddedNum}.\` \`${reminder.remind_at} (${result})\` ${reminder.body}`;
const prettyRemindAt = inGuildTz(pluginData, moment.utc(reminder.remind_at, DBDateFormat)).format(
getDateFormat(pluginData, "pretty_datetime"),
);
return `\`${paddedNum}.\` \`${prettyRemindAt} (${result})\` ${reminder.body}`;
});
createChunkedMessage(msg.channel, lines.join("\n"));