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