Fix: Utility-ServerInfo several fixes (#394)
This commit is contained in:
parent
7edc5f68eb
commit
7c2a50921b
1 changed files with 40 additions and 14 deletions
|
@ -16,6 +16,12 @@ import { idToTimestamp } from "../../../utils/idToTimestamp";
|
||||||
import { UtilityPluginType } from "../types";
|
import { UtilityPluginType } from "../types";
|
||||||
import { getGuildPreview } from "./getGuildPreview";
|
import { getGuildPreview } from "./getGuildPreview";
|
||||||
|
|
||||||
|
const prettifyFeature = (feature: string): string =>
|
||||||
|
`\`${feature
|
||||||
|
.split("_")
|
||||||
|
.map((e) => `${e.substring(0, 1).toUpperCase()}${e.substring(1).toLowerCase()}`)
|
||||||
|
.join(" ")}\``;
|
||||||
|
|
||||||
export async function getServerInfoEmbed(
|
export async function getServerInfoEmbed(
|
||||||
pluginData: GuildPluginData<UtilityPluginType>,
|
pluginData: GuildPluginData<UtilityPluginType>,
|
||||||
serverId: string,
|
serverId: string,
|
||||||
|
@ -62,19 +68,16 @@ export async function getServerInfoEmbed(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (features.length > 0) {
|
if (features.length > 0) {
|
||||||
basicInformation.push(`Features: ${features.join(", ")}`);
|
basicInformation.push(`Features: ${features.map(prettifyFeature).join(", ")}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
embed.fields.push({
|
embed.description = `${preEmbedPadding}**Basic Information**\n${basicInformation.join("\n")}`;
|
||||||
name: preEmbedPadding + "Basic information",
|
|
||||||
value: basicInformation.join("\n"),
|
|
||||||
});
|
|
||||||
|
|
||||||
// IMAGE LINKS
|
// IMAGE LINKS
|
||||||
const iconUrl = `[Link](${(restGuild || guildPreview)!.iconURL({ size: 2048 })})`;
|
const iconUrl = `[Link](${(restGuild || guildPreview)!.iconURL()})`;
|
||||||
const bannerUrl = restGuild?.banner ? `[Link](${restGuild.bannerURL({ size: 2048 })})` : "None";
|
const bannerUrl = restGuild?.banner ? `[Link](${restGuild.bannerURL()})` : "None";
|
||||||
const splashUrl = (restGuild || guildPreview)!.splash
|
const splashUrl = (restGuild || guildPreview)!.splash
|
||||||
? `[Link](${(restGuild || guildPreview)!.splashURL({ size: 2048 })})`
|
? `[Link](${(restGuild || guildPreview)!.splashURL()})`
|
||||||
: "None";
|
: "None";
|
||||||
|
|
||||||
embed.fields.push(
|
embed.fields.push(
|
||||||
|
@ -142,15 +145,21 @@ export async function getServerInfoEmbed(
|
||||||
|
|
||||||
// CHANNEL COUNTS
|
// CHANNEL COUNTS
|
||||||
if (thisServer) {
|
if (thisServer) {
|
||||||
const totalChannels = thisServer.channels.cache.size;
|
|
||||||
const categories = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildCategory);
|
const categories = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildCategory);
|
||||||
const textChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildText);
|
const textChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildText);
|
||||||
const voiceChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildVoice);
|
const voiceChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildVoice);
|
||||||
const threadChannels = thisServer.channels.cache.filter((channel) => channel.isThread());
|
const forumChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildForum);
|
||||||
|
const threadChannelsText = thisServer.channels.cache.filter(
|
||||||
|
(channel) => channel.isThread() && channel.parent?.type !== ChannelType.GuildForum,
|
||||||
|
);
|
||||||
|
const threadChannelsForums = thisServer.channels.cache.filter(
|
||||||
|
(channel) => channel.isThread() && channel.parent?.type === ChannelType.GuildForum,
|
||||||
|
);
|
||||||
const announcementChannels = thisServer.channels.cache.filter(
|
const announcementChannels = thisServer.channels.cache.filter(
|
||||||
(channel) => channel.type === ChannelType.GuildAnnouncement,
|
(channel) => channel.type === ChannelType.GuildAnnouncement,
|
||||||
);
|
);
|
||||||
const stageChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildStageVoice);
|
const stageChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildStageVoice);
|
||||||
|
const totalChannels = thisServer.channels.cache.filter((channel) => !channel.isThread()).size;
|
||||||
|
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: preEmbedPadding + "Channels",
|
name: preEmbedPadding + "Channels",
|
||||||
|
@ -158,7 +167,8 @@ export async function getServerInfoEmbed(
|
||||||
value: trimLines(`
|
value: trimLines(`
|
||||||
Total: **${totalChannels}** / 500
|
Total: **${totalChannels}** / 500
|
||||||
Categories: **${categories.size}**
|
Categories: **${categories.size}**
|
||||||
Text: **${textChannels.size}** (**${threadChannels.size} threads**)
|
Text: **${textChannels.size}** (**${threadChannelsText.size} threads**)
|
||||||
|
Forums: **${forumChannels.size}** (**${threadChannelsForums.size} threads**)
|
||||||
Announcement: **${announcementChannels.size}**
|
Announcement: **${announcementChannels.size}**
|
||||||
Voice: **${voiceChannels.size}**
|
Voice: **${voiceChannels.size}**
|
||||||
Stage: **${stageChannels.size}**
|
Stage: **${stageChannels.size}**
|
||||||
|
@ -173,6 +183,12 @@ export async function getServerInfoEmbed(
|
||||||
otherStats.push(`Roles: **${thisServer.roles.cache.size}** / 250`);
|
otherStats.push(`Roles: **${thisServer.roles.cache.size}** / 250`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const roleLockedEmojis =
|
||||||
|
(restGuild
|
||||||
|
? restGuild?.emojis?.cache.filter((e) => e.roles.cache.size)
|
||||||
|
: guildPreview?.emojis.filter((e) => e.roles.length)
|
||||||
|
)?.size ?? 0;
|
||||||
|
|
||||||
if (restGuild) {
|
if (restGuild) {
|
||||||
const maxEmojis =
|
const maxEmojis =
|
||||||
{
|
{
|
||||||
|
@ -189,15 +205,25 @@ export async function getServerInfoEmbed(
|
||||||
[GuildPremiumTier.Tier3]: 60,
|
[GuildPremiumTier.Tier3]: 60,
|
||||||
}[restGuild.premiumTier] ?? 0;
|
}[restGuild.premiumTier] ?? 0;
|
||||||
|
|
||||||
otherStats.push(`Emojis: **${restGuild.emojis.cache.size}** / ${maxEmojis * 2}`);
|
otherStats.push(
|
||||||
|
`Emojis: **${restGuild.emojis.cache.size}** / ${maxEmojis * 2}${
|
||||||
|
roleLockedEmojis ? ` (__${roleLockedEmojis} role-locked__)` : ""
|
||||||
|
}`,
|
||||||
|
);
|
||||||
otherStats.push(`Stickers: **${restGuild.stickers.cache.size}** / ${maxStickers}`);
|
otherStats.push(`Stickers: **${restGuild.stickers.cache.size}** / ${maxStickers}`);
|
||||||
} else {
|
} else {
|
||||||
otherStats.push(`Emojis: **${guildPreview!.emojis.size}**`);
|
otherStats.push(
|
||||||
|
`Emojis: **${guildPreview!.emojis.size}**${roleLockedEmojis ? ` (__${roleLockedEmojis} role-locked__)` : ""}`,
|
||||||
|
);
|
||||||
// otherStats.push(`Stickers: **${guildPreview!.stickers.size}**`); Wait on DJS
|
// otherStats.push(`Stickers: **${guildPreview!.stickers.size}**`); Wait on DJS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thisServer) {
|
if (thisServer) {
|
||||||
otherStats.push(`Boosts: **${thisServer.premiumSubscriptionCount ?? 0}** (level ${thisServer.premiumTier})`);
|
otherStats.push(
|
||||||
|
`Boosts: **${thisServer.premiumSubscriptionCount ?? 0}**${
|
||||||
|
thisServer.premiumTier ? ` (level ${thisServer.premiumTier})` : ""
|
||||||
|
}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
|
|
Loading…
Add table
Reference in a new issue