✨ GUILD_MEMBER_LIST_UPDATE
This commit is contained in:
parent
11d891f819
commit
910dd9a22b
2282
package-lock.json
generated
2282
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@
|
||||
"author": "Fosscord",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@fosscord/server-util": "^1.3.3",
|
||||
"@fosscord/server-util": "^1.3.7",
|
||||
"ajv": "^8.5.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
|
@ -1,13 +1,5 @@
|
||||
// @ts-nocheck WIP
|
||||
import {
|
||||
db,
|
||||
getPermission,
|
||||
MemberModel,
|
||||
MongooseCache,
|
||||
PublicUserProjection,
|
||||
RoleModel,
|
||||
toObject,
|
||||
} from "@fosscord/server-util";
|
||||
import { db, getPermission, MemberModel, MongooseCache, PublicUserProjection, RoleModel, toObject } from "@fosscord/server-util";
|
||||
import { LazyRequest } from "../schema/LazyRequest";
|
||||
import { OPCODES, Payload } from "../util/Constants";
|
||||
import { Send } from "../util/Send";
|
||||
@ -31,9 +23,10 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
||||
.aggregate([
|
||||
{
|
||||
$match: {
|
||||
guild_id,
|
||||
guild_id
|
||||
// id: { $ne: guild_id }
|
||||
// hoist: true // TODO: also match @everyone role
|
||||
},
|
||||
}
|
||||
},
|
||||
{ $sort: { position: 1 } },
|
||||
{
|
||||
@ -47,20 +40,17 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: { user_id: "$id" },
|
||||
pipeline: [
|
||||
{ $match: { $expr: { $eq: ["$id", "$$user_id"] } } },
|
||||
{ $project: PublicUserProjection },
|
||||
],
|
||||
as: "user",
|
||||
},
|
||||
pipeline: [{ $match: { $expr: { $eq: ["$id", "$$user_id"] } } }, { $project: PublicUserProjection }],
|
||||
as: "user"
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: "$user",
|
||||
},
|
||||
$unwind: "$user"
|
||||
}
|
||||
],
|
||||
as: "members",
|
||||
},
|
||||
},
|
||||
as: "members"
|
||||
}
|
||||
}
|
||||
])
|
||||
.toArray()
|
||||
);
|
||||
@ -73,10 +63,11 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
||||
items.push({
|
||||
group: {
|
||||
count: role.members.length,
|
||||
id: role.id,
|
||||
},
|
||||
id: role.id === guild_id ? "online" : role.name
|
||||
}
|
||||
});
|
||||
for (const member of role.members) {
|
||||
member.roles.remove(guild_id);
|
||||
items.push({ member });
|
||||
}
|
||||
}
|
||||
@ -90,14 +81,14 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
||||
{
|
||||
range: [0, 99],
|
||||
op: "SYNC",
|
||||
items: items,
|
||||
},
|
||||
items
|
||||
}
|
||||
],
|
||||
online_count: member_count, // TODO count online count
|
||||
member_count,
|
||||
id: "everyone",
|
||||
guild_id,
|
||||
groups,
|
||||
},
|
||||
groups
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user