mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Update to eris#dev
This commit is contained in:
parent
ab51231fef
commit
53b64682ee
5 changed files with 33 additions and 22 deletions
18
backend/package-lock.json
generated
18
backend/package-lock.json
generated
|
@ -1634,10 +1634,10 @@
|
|||
"dev": true
|
||||
},
|
||||
"eris": {
|
||||
"version": "https://github.com/Dragory/eris/archive/custom.tar.gz",
|
||||
"integrity": "sha512-6wb+mk7l/IDzqqki1IH0F8+U1dzGCbw7cHsg6dBVZ6emflHz+NnOND8XV3LPVnUQkw8ABIYzZhmYYXasURgmfg==",
|
||||
"version": "github:abalabahaha/eris#54fc78d3a1f9f8ebe8b072c9c87c674c8453d016",
|
||||
"from": "github:abalabahaha/eris#dev",
|
||||
"requires": {
|
||||
"opusscript": "^0.0.7",
|
||||
"opusscript": "^0.0.8",
|
||||
"tweetnacl": "^1.0.1",
|
||||
"ws": "^7.2.1"
|
||||
}
|
||||
|
@ -2883,9 +2883,9 @@
|
|||
}
|
||||
},
|
||||
"opusscript": {
|
||||
"version": "0.0.7",
|
||||
"resolved": "https://registry.npmjs.org/opusscript/-/opusscript-0.0.7.tgz",
|
||||
"integrity": "sha512-DcBadTdYTUuH9zQtepsLjQn4Ll6rs3dmeFvN+SD0ThPnxRBRm/WC1zXWPg+wgAJimB784gdZvUMA57gDP7FdVg==",
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/opusscript/-/opusscript-0.0.8.tgz",
|
||||
"integrity": "sha512-VSTi1aWFuCkRCVq+tx/BQ5q9fMnQ9pVZ3JU4UHKqTkf0ED3fKEPdr+gKAAl3IA2hj9rrP6iyq3hlcJq3HELtNQ==",
|
||||
"optional": true
|
||||
},
|
||||
"ora": {
|
||||
|
@ -4696,9 +4696,9 @@
|
|||
}
|
||||
},
|
||||
"ws": {
|
||||
"version": "7.4.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.0.tgz",
|
||||
"integrity": "sha512-kyFwXuV/5ymf+IXhS6f0+eAFvydbaBW3zjpT6hUdAh/hbVjTIB5EHBGi0bPoCLSK2wcuz3BrEkB9LrYv1Nm4NQ=="
|
||||
"version": "7.4.4",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.4.tgz",
|
||||
"integrity": "sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw=="
|
||||
},
|
||||
"xdg-basedir": {
|
||||
"version": "4.0.0",
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
"deep-diff": "^1.0.2",
|
||||
"dotenv": "^4.0.0",
|
||||
"emoji-regex": "^8.0.0",
|
||||
"eris": "https://github.com/Dragory/eris/archive/custom.tar.gz",
|
||||
"eris": "github:abalabahaha/eris#dev",
|
||||
"erlpack": "github:abalabahaha/erlpack",
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
"express": "^4.17.0",
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
EmbedWith,
|
||||
emptyEmbedValue,
|
||||
formatNumber,
|
||||
inviteHasCounts,
|
||||
isGroupDMInvite,
|
||||
isGuildInvite,
|
||||
preEmbedPadding,
|
||||
|
@ -50,13 +51,17 @@ export async function getInviteInfoEmbed(
|
|||
round: true,
|
||||
});
|
||||
|
||||
const memberCount = inviteHasCounts(invite) ? invite.memberCount : 0;
|
||||
|
||||
const presenceCount = inviteHasCounts(invite) ? invite.presenceCount : 0;
|
||||
|
||||
embed.fields.push({
|
||||
name: preEmbedPadding + "Server information",
|
||||
value: trimLines(`
|
||||
Name: **${invite.guild.name}**
|
||||
ID: \`${invite.guild.id}\`
|
||||
Created: **${serverAge} ago**
|
||||
Members: **${formatNumber(invite.memberCount)}** (${formatNumber(invite.presenceCount)} online)
|
||||
Members: **${formatNumber(memberCount)}** (${formatNumber(presenceCount)} online)
|
||||
`),
|
||||
inline: true,
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
embedPadding,
|
||||
EmbedWith,
|
||||
formatNumber,
|
||||
inviteHasCounts,
|
||||
memoize,
|
||||
MINUTES,
|
||||
preEmbedPadding,
|
||||
|
@ -120,7 +121,7 @@ export async function getServerInfoEmbed(
|
|||
if (onlineMemberCount == null && restGuild?.vanityURL) {
|
||||
// For servers with a vanity URL, we can also use the numbers from the invite for online count
|
||||
const invite = await resolveInvite(pluginData.client, restGuild.vanityURL!, true);
|
||||
if (invite) {
|
||||
if (invite && inviteHasCounts(invite)) {
|
||||
onlineMemberCount = invite.presenceCount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
GuildChannel,
|
||||
Invite,
|
||||
InvitePartialChannel,
|
||||
InviteWithMetadata,
|
||||
Member,
|
||||
Message,
|
||||
MessageContent,
|
||||
|
@ -181,11 +180,11 @@ export function nonNullish<V>(v: V): v is NonNullable<V> {
|
|||
return v != null;
|
||||
}
|
||||
|
||||
export type GuildInvite = Invite & { guild: Guild };
|
||||
export type GroupDMInvite = Invite & { channel: InvitePartialChannel; type: typeof Constants.ChannelTypes.GROUP_DM };
|
||||
export type WithInviteCounts = {
|
||||
memberCount: number;
|
||||
presenceCount: number;
|
||||
export type InviteOpts = "withMetadata" | "withCount" | "withoutCount";
|
||||
export type GuildInvite<CT extends InviteOpts = "withMetadata"> = Invite<CT> & { guild: Guild };
|
||||
export type GroupDMInvite<CT extends InviteOpts = "withMetadata"> = Invite<CT> & {
|
||||
channel: InvitePartialChannel;
|
||||
type: typeof Constants.ChannelTypes.GROUP_DM;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1153,9 +1152,11 @@ export async function resolveRoleId(bot: Client, guildId: string, value: string)
|
|||
return null;
|
||||
}
|
||||
|
||||
const inviteCache = new SimpleCache<Promise<(Invite | (Invite & InviteWithMetadata)) | null>>(10 * MINUTES, 200);
|
||||
const inviteCache = new SimpleCache<Promise<Invite<any> | null>>(10 * MINUTES, 200);
|
||||
|
||||
type ResolveInviteReturnType<T extends boolean> = Promise<(T extends true ? Invite & WithInviteCounts : Invite) | null>;
|
||||
type ResolveInviteReturnType<T extends boolean> = Promise<
|
||||
(T extends true ? Invite<"withCount" | "withMetadata"> : Invite<"withMetadata">) | null
|
||||
>;
|
||||
export async function resolveInvite<T extends boolean>(
|
||||
client: Client,
|
||||
code: string,
|
||||
|
@ -1330,14 +1331,18 @@ export function isFullMessage(msg: PossiblyUncachedMessage): msg is Message {
|
|||
return (msg as Message).createdAt != null;
|
||||
}
|
||||
|
||||
export function isGuildInvite(invite: Invite): invite is GuildInvite {
|
||||
export function isGuildInvite<CT extends InviteOpts>(invite: Invite<CT>): invite is GuildInvite<CT> {
|
||||
return invite.guild != null;
|
||||
}
|
||||
|
||||
export function isGroupDMInvite(invite: Invite): invite is GroupDMInvite {
|
||||
export function isGroupDMInvite<CT extends InviteOpts>(invite: Invite<CT>): invite is GroupDMInvite<CT> {
|
||||
return invite.guild == null && invite.channel?.type === Constants.ChannelTypes.GROUP_DM;
|
||||
}
|
||||
|
||||
export function inviteHasCounts(invite: Invite<any>): invite is Invite<"withCount"> {
|
||||
return invite.memberCount != null;
|
||||
}
|
||||
|
||||
export function asyncMap<T, R>(arr: T[], fn: (item: T) => Promise<R>): Promise<R[]> {
|
||||
return Promise.all(arr.map((item, index) => fn(item)));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue