Skip to content

Commit 762287e

Browse files
Merge pull request #1233 from dank074/patch/fixOp8
fix opcode 8 handler: onRequestGuildMembers
2 parents c51595a + bcbd823 commit 762287e

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

Diff for: src/gateway/opcodes/RequestGuildMembers.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
} from "@spacebar/util";
2828
import { WebSocket, Payload, OPCODES, Send } from "@spacebar/gateway";
2929
import { check } from "./instanceOf";
30-
import { FindManyOptions, In, Like } from "typeorm";
30+
import { FindManyOptions, ILike, In } from "typeorm";
3131

3232
export async function onRequestGuildMembers(this: WebSocket, { d }: Payload) {
3333
// Schema validation can only accept either string or array, so transforming it here to support both
@@ -114,7 +114,7 @@ export async function onRequestGuildMembers(this: WebSocket, { d }: Payload) {
114114
if (query) {
115115
// @ts-expect-error memberFind.where is very much defined
116116
memberFind.where.user = {
117-
username: Like(query + "%"),
117+
username: ILike(query + "%"),
118118
};
119119
} else if (user_ids && user_ids.length > 0) {
120120
// @ts-expect-error memberFind.where is still very much defined
@@ -166,15 +166,17 @@ export async function onRequestGuildMembers(this: WebSocket, { d }: Payload) {
166166
});
167167
}
168168

169+
if (chunks.length == 0) {
170+
chunks.push({
171+
...baseData,
172+
members: [],
173+
presences: presences ? [] : undefined,
174+
chunk_index: 0,
175+
chunk_count: 1,
176+
});
177+
}
178+
169179
if (notFound.length > 0) {
170-
if (chunks.length == 0)
171-
chunks.push({
172-
...baseData,
173-
members: [],
174-
presences: presences ? [] : undefined,
175-
chunk_index: 0,
176-
chunk_count: 1,
177-
});
178180
chunks[0].not_found = notFound;
179181
}
180182

Diff for: src/util/entities/Member.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ export class Member extends BaseClassWithoutId {
466466
member[x] = this[x];
467467
});
468468

469-
if (member.roles) member.roles = member.roles.map((x: Role) => x.id);
470-
if (member.user) member.user = member.user.toPublicUser();
469+
if (this.roles) member.roles = this.roles.map((x: Role) => x.id);
470+
if (this.user) member.user = this.user.toPublicUser();
471471

472472
return member as PublicMember;
473473
}

0 commit comments

Comments
 (0)