Add time_and_date plugin. Use it for timezones and date formats around the bot.
This commit is contained in:
parent
cffb0dbd6b
commit
4ae8cf85a3
67 changed files with 543 additions and 177 deletions
|
@ -5,12 +5,12 @@ 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";
|
||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
||||
|
||||
export async function getServerInfoEmbed(
|
||||
pluginData: PluginData<UtilityPluginType>,
|
||||
serverId: string,
|
||||
requestMemberId?: string,
|
||||
): Promise<EmbedOptions> {
|
||||
const thisServer = serverId === pluginData.guild.id ? pluginData.guild : null;
|
||||
const [restGuild, guildPreview] = await Promise.all([
|
||||
|
@ -39,8 +39,12 @@ export async function getServerInfoEmbed(
|
|||
};
|
||||
|
||||
// BASIC INFORMATION
|
||||
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
|
||||
const createdAt = moment.utc((guildPreview || restGuild).createdAt, "x");
|
||||
const prettyCreatedAt = inGuildTz(pluginData, createdAt).format(getDateFormat(pluginData, "pretty_datetime"));
|
||||
const tzCreatedAt = requestMemberId
|
||||
? await timeAndDate.inMemberTz(requestMemberId, createdAt)
|
||||
: timeAndDate.inGuildTz(createdAt);
|
||||
const prettyCreatedAt = tzCreatedAt.format(timeAndDate.getDateFormat("pretty_datetime"));
|
||||
const serverAge = humanizeDuration(moment.utc().valueOf() - createdAt.valueOf(), {
|
||||
largest: 2,
|
||||
round: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue