1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-23 19:02:37 +01:00

🐛 also receive events for newly added members/relationships

This commit is contained in:
Flam3rboy 2021-10-17 22:28:15 +02:00
parent 3a76f0f33c
commit 5c38999afa

View File

@ -117,7 +117,7 @@ export async function setupListener(this: WebSocket) {
// TODO: only subscribe for events that are in the connection intents
async function consume(this: WebSocket, opts: EventOpts) {
const { data, event } = opts;
const id = data.id as string;
let id = data.id as string;
const permission = this.permissions[id] || new Permissions("ADMINISTRATOR"); // default permission for dm
const consumer = consume.bind(this);
@ -138,6 +138,10 @@ async function consume(this: WebSocket, opts: EventOpts) {
this.listen_options
);
break;
case "GUILD_MEMBER_REMOVE":
if (!this.member_events[data.user.id]) break;
this.member_events[data.user.id]();
break;
case "RELATIONSHIP_REMOVE":
case "CHANNEL_DELETE":
case "GUILD_DELETE":
@ -152,6 +156,13 @@ async function consume(this: WebSocket, opts: EventOpts) {
)
return;
// No break needed here, we need to call the listenEvent function below
case "RELATIONSHIP_ADD":
this.events[data.user.id] = await listenEvent(
data.user.id,
handlePresenceUpdate.bind(this),
this.listen_options
);
break;
case "GUILD_CREATE":
this.events[id] = await listenEvent(id, consumer, listenOpts);
break;