summary refs log tree commit diff
path: root/src/listener
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-18 22:04:29 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-18 22:04:29 +0200
commitda08497a19ab0635a8bd78e499cfc61e54352dcc (patch)
tree7fcda3b1ebca8e8a902c066945e02206b089fe51 /src/listener
parentMerge branch 'master' of https://github.com/discord-open-source/discord-gateway (diff)
downloadserver-da08497a19ab0635a8bd78e499cfc61e54352dcc.tar.xz
:construction: WIP member list + voice
Diffstat (limited to 'src/listener')
-rw-r--r--src/listener/listener.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/listener/listener.ts b/src/listener/listener.ts

index e3516993..54cdb47d 100644 --- a/src/listener/listener.ts +++ b/src/listener/listener.ts
@@ -17,7 +17,7 @@ export interface DispatchOpts { guilds: Array<string>; } -function getPipeline(this: WebSocket, guilds: string[]) { +function getPipeline(this: WebSocket, guilds: string[], channels: string[]) { if (this.shard_count) { guilds = guilds.filter((x) => (BigInt(x) >> 22n) % this.shard_count === this.shard_id); } @@ -25,7 +25,11 @@ function getPipeline(this: WebSocket, guilds: string[]) { return [ { $match: { - $or: [{ "fullDocument.guild_id": { $in: guilds } }, { "fullDocument.user_id": this.user_id }], + $or: [ + { "fullDocument.guild_id": { $in: guilds } }, + { "fullDocument.user_id": this.user_id }, + { "fullDocument.channel_id": { $in: channels } }, + ], }, }, ]; @@ -45,6 +49,8 @@ export async function setupListener(this: WebSocket) { this.once("close", () => eventStream.destroy()); } +// TODO: cache permission + export async function dispatch(this: WebSocket, document: Event, { eventStream, guilds }: DispatchOpts) { var permission = new Permissions("ADMINISTRATOR"); // default permission for dms console.log("event", document);