3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +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,5 +1,4 @@
import { APIEmbed, ChannelType } from "discord.js";
import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub";
import {
EmbedWith,
@ -44,10 +43,6 @@ export async function getInviteInfoEmbed(
}
const serverCreatedAtTimestamp = snowflakeToTimestamp(invite.guild.id);
const serverAge = humanizeDuration(Date.now() - serverCreatedAtTimestamp, {
largest: 2,
round: true,
});
const memberCount = inviteHasCounts(invite) ? invite.memberCount : 0;
@ -58,7 +53,7 @@ export async function getInviteInfoEmbed(
value: trimLines(`
Name: **${invite.guild.name}**
ID: \`${invite.guild.id}\`
Created: **${serverAge} ago**
Created: **<t:${Math.round(serverCreatedAtTimestamp / 1000)}:R>**
Members: **${formatNumber(memberCount)}** (${formatNumber(presenceCount)} online)
`),
inline: true,
@ -68,15 +63,11 @@ export async function getInviteInfoEmbed(
invite.channel.type === ChannelType.GuildVoice ? `🔉 ${invite.channel.name}` : `#${invite.channel.name}`;
const channelCreatedAtTimestamp = snowflakeToTimestamp(invite.channel.id);
const channelAge = humanizeDuration(Date.now() - channelCreatedAtTimestamp, {
largest: 2,
round: true,
});
let channelInfo = trimLines(`
Name: **${channelName}**
ID: \`${invite.channel.id}\`
Created: **${channelAge} ago**
Created: **<t:${Math.round(channelCreatedAtTimestamp / 1000)}:R>**
`);
if (invite.channel.type !== ChannelType.GuildVoice) {
@ -120,17 +111,13 @@ export async function getInviteInfoEmbed(
}*/
const channelCreatedAtTimestamp = snowflakeToTimestamp(invite.channel!.id);
const channelAge = humanizeDuration(Date.now() - channelCreatedAtTimestamp, {
largest: 2,
round: true,
});
embed.fields.push({
name: preEmbedPadding + "Group DM information",
value: trimLines(`
Name: ${invite.channel!.name ? `**${invite.channel!.name}**` : `_Unknown_`}
ID: \`${invite.channel!.id}\`
Created: **${channelAge} ago**
Created: **<t:${Math.round(channelCreatedAtTimestamp / 1000)}:R>**
Members: **${formatNumber((invite as any).memberCount)}**
`),
inline: true,