Finish preliminary rework, ready to test
This commit is contained in:
parent
57893e7f76
commit
d0a1beb809
177 changed files with 854 additions and 707 deletions
|
@ -9,6 +9,7 @@ import {
|
|||
EmbedWith,
|
||||
emptyEmbedValue,
|
||||
formatNumber,
|
||||
GroupDMInvite,
|
||||
inviteHasCounts,
|
||||
isGroupDMInvite,
|
||||
isGuildInvite,
|
||||
|
@ -16,12 +17,14 @@ import {
|
|||
resolveInvite,
|
||||
trimLines,
|
||||
} from "../../../utils";
|
||||
import { MessageEmbedOptions, Constants, Invite } from "discord.js";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
|
||||
export async function getInviteInfoEmbed(
|
||||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
inviteCode: string,
|
||||
): Promise<EmbedOptions | null> {
|
||||
const invite = await resolveInvite(pluginData.client, inviteCode, true);
|
||||
): Promise<MessageEmbedOptions | null> {
|
||||
let invite = await resolveInvite(pluginData.client, inviteCode, true);
|
||||
if (!invite) {
|
||||
return null;
|
||||
}
|
||||
|
@ -67,9 +70,7 @@ export async function getInviteInfoEmbed(
|
|||
});
|
||||
|
||||
const channelName =
|
||||
invite.channel.type === Constants.ChannelTypes.GUILD_VOICE
|
||||
? `🔉 ${invite.channel.name}`
|
||||
: `#${invite.channel.name}`;
|
||||
invite.channel.type === ChannelTypeStrings.VOICE ? `🔉 ${invite.channel.name}` : `#${invite.channel.name}`;
|
||||
|
||||
const channelCreatedAtTimestamp = snowflakeToTimestamp(invite.channel.id);
|
||||
const channelCreatedAt = moment.utc(channelCreatedAtTimestamp, "x");
|
||||
|
@ -84,7 +85,7 @@ export async function getInviteInfoEmbed(
|
|||
Created: **${channelAge} ago**
|
||||
`);
|
||||
|
||||
if (invite.channel.type !== Constants.ChannelTypes.GUILD_VOICE) {
|
||||
if (invite.channel.type !== ChannelTypeStrings.VOICE) {
|
||||
channelInfo += `\nMention: <#${invite.channel.id}>`;
|
||||
}
|
||||
|
||||
|
@ -113,16 +114,17 @@ export async function getInviteInfoEmbed(
|
|||
fields: [],
|
||||
};
|
||||
|
||||
invite = invite as GroupDMInvite;
|
||||
embed.author = {
|
||||
name: invite.channel.name ? `Group DM invite: ${invite.channel.name}` : `Group DM invite`,
|
||||
url: `https://discord.gg/${invite.code}`,
|
||||
};
|
||||
}; // FIXME pending invite re-think
|
||||
|
||||
if (invite.channel.icon) {
|
||||
/*if (invite.channel.icon) {
|
||||
embed.author.icon_url = `https://cdn.discordapp.com/channel-icons/${invite.channel.id}/${invite.channel.icon}.png?size=256`;
|
||||
}
|
||||
|
||||
const channelCreatedAtTimestamp = snowflakeToTimestamp(invite.channel.id);
|
||||
}*/ const channelCreatedAtTimestamp = snowflakeToTimestamp(
|
||||
invite.channel.id,
|
||||
);
|
||||
const channelCreatedAt = moment.utc(channelCreatedAtTimestamp, "x");
|
||||
const channelAge = humanizeDuration(Date.now() - channelCreatedAtTimestamp, {
|
||||
largest: 2,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue