Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
fix: fix notInArray
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazmi35 authored Feb 24, 2024
1 parent 1549b50 commit 585f937
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
11 changes: 7 additions & 4 deletions packages/core/src/Structures/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,14 @@ export class Client extends EventEmitter {
});

if ("permission_overwrites" in channel && channel.permission_overwrites !== undefined) {
const lists = channel.permission_overwrites.map(x => x.id);
await this.store.delete(schema.channelsOverwrite).where(
and(
eq(schema.channelsOverwrite.channelId, channel.id),
notInArray(schema.channelsOverwrite.userOrRole, channel.permission_overwrites.map(x => x.id))
)
lists.length > 0
? and(
eq(schema.channelsOverwrite.channelId, channel.id),
notInArray(schema.channelsOverwrite.userOrRole, lists)
)
: eq(schema.channelsOverwrite.channelId, channel.id)
);

if (channel.permission_overwrites.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ export class ChannelUpdateListener extends Listener {
});

if ("permission_overwrites" in payload.data.d && payload.data.d.permission_overwrites !== undefined) {
const lists = payload.data.d.permission_overwrites.map(x => x.id);
await this.container.client.drizzle.delete(channelsOverwrite).where(
and(
eq(channelsOverwrite.channelId, payload.data.d.id),
notInArray(channelsOverwrite.userOrRole, payload.data.d.permission_overwrites.map(x => x.id))
)
lists.length > 0
? and(
eq(channelsOverwrite.channelId, payload.data.d.id),
notInArray(channelsOverwrite.userOrRole, lists)
)
: eq(channelsOverwrite.channelId, payload.data.d.id)
);

if (payload.data.d.permission_overwrites.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ export class GuildMemberUpdateListener extends Listener {
}
});

const lists = payload.data.d.roles;
await this.container.client.drizzle.delete(memberRoles).where(
and(
eq(memberRoles.memberId, payload.data.d.user.id),
notInArray(memberRoles.roleId, payload.data.d.roles)
)
lists.length > 0
? and(
eq(memberRoles.memberId, payload.data.d.user.id),
notInArray(memberRoles.roleId, lists)
)
: eq(memberRoles.memberId, payload.data.d.user.id)
);

if (payload.data.d.roles.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,14 @@ export class GuildCreateListener extends Listener {
"permission_overwrites" in ch &&
ch.permission_overwrites !== undefined
) {
const lists = ch.permission_overwrites.map(x => x.id);
await this.container.client.drizzle.delete(channelsOverwrite).where(
and(
eq(channelsOverwrite.channelId, ch.id),
notInArray(channelsOverwrite.userOrRole, ch.permission_overwrites.map(x => x.id))
)
lists.length > 0
? and(
eq(channelsOverwrite.channelId, ch.id),
notInArray(channelsOverwrite.userOrRole, lists)
)
: eq(channelsOverwrite.channelId, ch.id)
);

if (ch.permission_overwrites.length > 0) {
Expand Down

0 comments on commit 585f937

Please sign in to comment.