mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
changes to serverinfo and fixes in utils
This commit is contained in:
parent
3c6c9ebecf
commit
5fad488a63
2 changed files with 16 additions and 15 deletions
|
@ -1,7 +1,8 @@
|
|||
import { CategoryChannel, MessageEmbedOptions, Snowflake, TextChannel, VoiceChannel } from "discord.js";
|
||||
import { MessageEmbedOptions, Snowflake } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { ChannelTypeStrings } from "../../../types";
|
||||
import {
|
||||
EmbedWith,
|
||||
formatNumber,
|
||||
|
@ -82,12 +83,11 @@ export async function getServerInfoEmbed(
|
|||
});
|
||||
|
||||
// IMAGE LINKS
|
||||
const iconUrl = `[Link](${(restGuild || guildPreview)!.iconURL()})`;
|
||||
const bannerUrl = restGuild?.bannerURL() ? `[Link](${restGuild.bannerURL()})` : "None";
|
||||
const splashUrl =
|
||||
(restGuild || guildPreview)!.splashURL() != null
|
||||
? `[Link](${(restGuild || guildPreview)!.splashURL()?.replace("size=128", "size=2048")})`
|
||||
: "None";
|
||||
const iconUrl = `[Link](${(restGuild || guildPreview)!.iconURL({ dynamic: true, format: "png", size: 2048 })})`;
|
||||
const bannerUrl = restGuild?.banner ? `[Link](${restGuild.bannerURL({ format: "png", size: 2048 })})` : "None";
|
||||
const splashUrl = (restGuild || guildPreview)!.splash
|
||||
? `[Link](${(restGuild || guildPreview)!.splashURL({ format: "png", size: 2048 })})`
|
||||
: "None";
|
||||
|
||||
embed.fields.push(
|
||||
{
|
||||
|
@ -155,9 +155,9 @@ export async function getServerInfoEmbed(
|
|||
// CHANNEL COUNTS
|
||||
if (thisServer) {
|
||||
const totalChannels = thisServer.channels.cache.size;
|
||||
const categories = thisServer.channels.cache.filter(channel => channel instanceof CategoryChannel);
|
||||
const textChannels = thisServer.channels.cache.filter(channel => channel instanceof TextChannel);
|
||||
const voiceChannels = thisServer.channels.cache.filter(channel => channel instanceof VoiceChannel);
|
||||
const categories = thisServer.channels.cache.filter(channel => channel.type === ChannelTypeStrings.CATEGORY);
|
||||
const textChannels = thisServer.channels.cache.filter(channel => channel.type === ChannelTypeStrings.TEXT);
|
||||
const voiceChannels = thisServer.channels.cache.filter(channel => channel.type === ChannelTypeStrings.VOICE);
|
||||
|
||||
embed.fields.push({
|
||||
name: preEmbedPadding + "Channels",
|
||||
|
|
|
@ -1282,7 +1282,7 @@ export async function resolveRoleId(bot: Client, guildId: string, value: string)
|
|||
}
|
||||
|
||||
// Role name
|
||||
const roleList = await (await bot.guilds.fetch(guildId as Snowflake)).roles.cache;
|
||||
const roleList = (await bot.guilds.fetch(guildId as Snowflake)).roles.cache;
|
||||
const role = roleList.filter(x => x.name.toLocaleLowerCase() === value.toLocaleLowerCase());
|
||||
if (role[0]) {
|
||||
return role[0].id;
|
||||
|
@ -1310,7 +1310,6 @@ export async function resolveInvite<T extends boolean>(
|
|||
return inviteCache.get(key) as ResolveInviteReturnType<T>;
|
||||
}
|
||||
|
||||
// @ts-ignore: the getInvite() withCounts typings are blergh
|
||||
const promise = client.fetchInvite(code).catch(() => null);
|
||||
inviteCache.set(key, promise);
|
||||
|
||||
|
@ -1319,12 +1318,14 @@ export async function resolveInvite<T extends boolean>(
|
|||
|
||||
const internalStickerCache: LimitedCollection<Snowflake, Sticker> = new LimitedCollection(500);
|
||||
|
||||
export async function resolveStickerId(bot: Client, id: Snowflake): Promise<Sticker> {
|
||||
export async function resolveStickerId(bot: Client, id: Snowflake): Promise<Sticker | null> {
|
||||
const cachedSticker = internalStickerCache.get(id);
|
||||
if (cachedSticker) return cachedSticker;
|
||||
|
||||
const fetchedSticker = await bot.fetchSticker(id).catch(undefined);
|
||||
internalStickerCache.set(id, fetchedSticker);
|
||||
const fetchedSticker = await bot.fetchSticker(id).catch(() => null);
|
||||
if (fetchedSticker) {
|
||||
internalStickerCache.set(id, fetchedSticker);
|
||||
}
|
||||
|
||||
return fetchedSticker;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue