mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-06 10:52:31 +01:00
Send offline member group in LazyRequest
This commit is contained in:
parent
4fbebe17d3
commit
706831406e
@ -42,6 +42,8 @@ async function getMembers(guild_id: string, range: [number, number]) {
|
||||
.flat()
|
||||
.unique((r: Role) => r.id);
|
||||
|
||||
const offlineMembers = [];
|
||||
|
||||
for (const role of member_roles) {
|
||||
// @ts-ignore
|
||||
const [role_members, other_members] = partition(members, (m: Member) =>
|
||||
@ -56,6 +58,12 @@ async function getMembers(guild_id: string, range: [number, number]) {
|
||||
groups.push(group);
|
||||
|
||||
for (const member of role_members) {
|
||||
if (!member?.user?.sessions || !member.user.sessions.length) {
|
||||
offlineMembers.push(member);
|
||||
group.count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
const roles = member.roles
|
||||
.filter((x: Role) => x.id !== guild_id)
|
||||
.map((x: Role) => x.id);
|
||||
@ -79,6 +87,36 @@ async function getMembers(guild_id: string, range: [number, number]) {
|
||||
members = other_members;
|
||||
}
|
||||
|
||||
if (offlineMembers.length) {
|
||||
const group = {
|
||||
count: offlineMembers.length,
|
||||
id: "offline",
|
||||
};
|
||||
items.push({ group });
|
||||
groups.push(group);
|
||||
|
||||
for (var member of offlineMembers) {
|
||||
const roles = member.roles
|
||||
.filter((x: Role) => x.id !== guild_id)
|
||||
.map((x: Role) => x.id);
|
||||
|
||||
const session = member.user.sessions.first();
|
||||
|
||||
items.push({
|
||||
member: {
|
||||
...member,
|
||||
roles,
|
||||
user: { ...member.user, sessions: undefined },
|
||||
presence: {
|
||||
...session,
|
||||
activities: session?.activities || [],
|
||||
user: { id: member.user.id },
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
items,
|
||||
groups,
|
||||
|
Loading…
Reference in New Issue
Block a user