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

@ -5,6 +5,8 @@ import { CategoryChannel, EmbedOptions, Guild, RESTChannelInvite, TextChannel, V
import moment from "moment-timezone";
import humanizeDuration from "humanize-duration";
import { getGuildPreview } from "./getGuildPreview";
import { inGuildTz } from "../../../utils/timezones";
import { getDateFormat } from "../../../utils/dateFormats";
export async function getServerInfoEmbed(
pluginData: PluginData<UtilityPluginType>,
@ -37,14 +39,15 @@ export async function getServerInfoEmbed(
};
// BASIC INFORMATION
const createdAt = moment((guildPreview || restGuild).createdAt);
const serverAge = humanizeDuration(moment().valueOf() - createdAt.valueOf(), {
const createdAt = moment.utc((guildPreview || restGuild).createdAt, "x");
const prettyCreatedAt = inGuildTz(pluginData, createdAt).format(getDateFormat(pluginData, "pretty_datetime"));
const serverAge = humanizeDuration(moment.utc().valueOf() - createdAt.valueOf(), {
largest: 2,
round: true,
});
const basicInformation = [];
basicInformation.push(`Created: **${serverAge} ago** (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})`);
basicInformation.push(`Created: **${serverAge} ago** (${prettyCreatedAt})`);
if (thisServer) {
const owner = await resolveUser(pluginData.client, thisServer.ownerID);