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

@ -4,6 +4,8 @@ import { isOwner, sendErrorMessage } from "src/pluginUtils";
import { confirm, SECONDS, noop } from "src/utils";
import moment from "moment-timezone";
import { rehostAttachment } from "../rehostAttachment";
import { inGuildTz } from "../../../utils/timezones";
import { getDateFormat } from "../../../utils/dateFormats";
const MAX_ARCHIVED_MESSAGES = 5000;
const MAX_MESSAGES_PER_FETCH = 100;
@ -96,7 +98,7 @@ export const ArchiveChannelCmd = channelArchiverCmd({
archiveLines.reverse();
const nowTs = moment().format("YYYY-MM-DD HH:mm:ss");
const nowTs = inGuildTz(pluginData).format(getDateFormat(pluginData, "pretty_datetime"));
let result = `Archived ${archiveLines.length} messages from #${args.channel.name} at ${nowTs}`;
result += `\n\n${archiveLines.join("\n")}\n`;
@ -104,7 +106,7 @@ export const ArchiveChannelCmd = channelArchiverCmd({
progressMsg.delete().catch(noop);
msg.channel.createMessage("Archive created!", {
file: Buffer.from(result),
name: `archive-${args.channel.name}-${moment().format("YYYY-MM-DD-HH-mm-ss")}.txt`,
name: `archive-${args.channel.name}-${moment.utc().format("YYYY-MM-DD-HH-mm-ss")}.txt`,
});
},
});