feat: support role ordering events

This commit is contained in:
izzy
2025-08-07 16:55:11 +02:00
parent cd9e84a337
commit a45710f80c
2 changed files with 23 additions and 2 deletions
+18 -2
View File
@@ -257,7 +257,7 @@ export class WebSocketClient {
if (
packet.author !==
"00000000000000000000000000" &&
"00000000000000000000000000" &&
!packet.webhook
)
await server.fetchMember(packet.author);
@@ -588,6 +588,22 @@ export class WebSocketClient {
break;
}
case "ServerRoleRanksUpdate": {
const server = this.client.servers.get(packet.id);
if (server) {
server.roles = Object.entries(server.roles ?? {})
.map(([id, role]) => [id, {
...role,
rank: packet.ranks.findIndex(roleId => id === roleId)
}] as const)
.filter(([_, role]) => role.rank !== -1)
.reduce((d, [id, role]) => ({ ...d, [id]: role }), {});
// NB. no event for client here
}
break;
}
case "ServerRoleDelete": {
const server = this.client.servers.get(packet.id);
if (server) {
@@ -628,7 +644,7 @@ export class WebSocketClient {
].find(
(channel) =>
channel.channel_type ===
"DirectMessage" &&
"DirectMessage" &&
channel.recipient_ids?.includes(
user_id,
),
+5
View File
@@ -120,6 +120,11 @@ export type ClientboundNotification =
role_id: string;
data: Partial<Role>;
}
| {
type: "ServerRoleRanksUpdate";
id: string;
ranks: string[];
}
| { type: "ServerRoleDelete"; id: string; role_id: string }
| {
type: "UserUpdate";