3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-15 22:25:04 +00:00

feat: use native timestamps more

This commit is contained in:
Dragory 2023-06-24 11:55:49 +00:00
parent 0e70412bc4
commit ecaa16bf7c
10 changed files with 22 additions and 160 deletions

View file

@ -1,10 +1,7 @@
import { APIEmbed, PermissionFlagsBits, Role } from "discord.js";
import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub";
import moment from "moment-timezone";
import { EmbedWith, preEmbedPadding, trimLines } from "../../../utils";
import { PERMISSION_NAMES } from "../../../utils/permissionNames.js";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { UtilityPluginType } from "../types";
const MENTION_ICON = "https://cdn.discordapp.com/attachments/705009450855039042/839284872152481792/mention.png";
@ -23,17 +20,6 @@ export async function getRoleInfoEmbed(
color: role.color,
};
const createdAt = moment.utc(role.createdAt, "x");
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
const tzCreatedAt = requestMemberId
? await timeAndDate.inMemberTz(requestMemberId, createdAt)
: timeAndDate.inGuildTz(createdAt);
const prettyCreatedAt = tzCreatedAt.format(timeAndDate.getDateFormat("pretty_datetime"));
const roleAge = humanizeDuration(Date.now() - role.createdTimestamp, {
largest: 2,
round: true,
});
const rolePerms = role.permissions.has(PermissionFlagsBits.Administrator)
? [PERMISSION_NAMES.Administrator]
: role.permissions.toArray().map((p) => PERMISSION_NAMES[p]);
@ -46,7 +32,7 @@ export async function getRoleInfoEmbed(
value: trimLines(`
Name: **${role.name}**
ID: \`${role.id}\`
Created: **${roleAge} ago** (\`${prettyCreatedAt}\`)
Created: **<t:${Math.round(role.createdTimestamp / 1000)}:R>**
Position: **${role.position} / ${totalGuildRoles}**
Color: **#${role.color.toString(16).toUpperCase().padStart(6, "0")}**
Mentionable: **${role.mentionable ? "Yes" : "No"}**