Skip to content

Commit

Permalink
fix op 8
Browse files Browse the repository at this point in the history
  • Loading branch information
dank074 committed Nov 14, 2024
1 parent c51595a commit bcbd823
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions src/gateway/opcodes/RequestGuildMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from "@spacebar/util";
import { WebSocket, Payload, OPCODES, Send } from "@spacebar/gateway";
import { check } from "./instanceOf";
import { FindManyOptions, In, Like } from "typeorm";
import { FindManyOptions, ILike, In } from "typeorm";

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

if (chunks.length == 0) {
chunks.push({
...baseData,
members: [],
presences: presences ? [] : undefined,
chunk_index: 0,
chunk_count: 1,
});
}

if (notFound.length > 0) {
if (chunks.length == 0)
chunks.push({
...baseData,
members: [],
presences: presences ? [] : undefined,
chunk_index: 0,
chunk_count: 1,
});
chunks[0].not_found = notFound;
}

Expand Down
4 changes: 2 additions & 2 deletions src/util/entities/Member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ export class Member extends BaseClassWithoutId {
member[x] = this[x];
});

if (member.roles) member.roles = member.roles.map((x: Role) => x.id);
if (member.user) member.user = member.user.toPublicUser();
if (this.roles) member.roles = this.roles.map((x: Role) => x.id);
if (this.user) member.user = this.user.toPublicUser();

return member as PublicMember;
}
Expand Down

0 comments on commit bcbd823

Please sign in to comment.