diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index 252fb8f9e..39ab04e4b 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -280,7 +280,7 @@ export class Channel extends BaseClass { if (!ur.channel.recipients) continue; const re = ur.channel.recipients.map((r) => r.user_id); if (re.length === channelRecipients.length) { - if (re.containsAll(channelRecipients)) { + if (channelRecipients.every((_) => re.includes(_))) { if (channel == null) { channel = ur.channel; await ur.assign({ closed: false }).save(); @@ -429,7 +429,7 @@ export class Channel extends BaseClass { } async getUserPermissions(opts: { user_id?: string; user?: User; member?: Member; guild?: Guild }): Promise { - if(this.isDm()) this.owner_id == (opts.user_id ?? opts.user?.id) ? Permissions.ALL : Permissions.DEFAULT_DM_PERMISSIONS; + if (this.isDm()) return this.owner_id == (opts.user_id ?? opts.user?.id) ? Permissions.ALL : Permissions.DEFAULT_DM_PERMISSIONS; let guild = opts.guild; if (!guild) { if (this.guild) guild = this.guild; @@ -470,7 +470,7 @@ export class Channel extends BaseClass { position: true, }, }, - loadEagerRelations: false + loadEagerRelations: false, }) ).roles ).sort((a, b) => a.position - b.position); // ascending by position diff --git a/src/util/util/extensions/Array.test.ts b/src/util/util/extensions/Array.test.ts index 432e9a590..1dea2cf43 100644 --- a/src/util/util/extensions/Array.test.ts +++ b/src/util/util/extensions/Array.test.ts @@ -5,18 +5,6 @@ import { describe, it } from "node:test"; import assert from "node:assert/strict"; describe("Array extensions", () => { - it("containsAll", () => { - const arr = [1, 2, 3, 4, 5]; - assert(arr.containsAll([1, 2])); - assert(!arr.containsAll([1, 6])); - assert(arr.containsAll([])); - assert([].containsAll([])); - - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error - assert(![].containsAll([1])); - }); - it("partition", () => { const arr = [1, 2, 3, 4, 5]; const [even, odd] = arr.partition((n) => n % 2 === 0); diff --git a/src/util/util/extensions/Array.ts b/src/util/util/extensions/Array.ts index eec76a0fb..f8ca31894 100644 --- a/src/util/util/extensions/Array.ts +++ b/src/util/util/extensions/Array.ts @@ -18,7 +18,6 @@ declare global { interface Array { - containsAll(target: T[]): boolean; partition(filter: (elem: T) => boolean): [T[], T[]]; forEachAsync(callback: (elem: T, index: number, array: T[]) => Promise): Promise; filterAsync(callback: (elem: T, index: number, array: T[]) => Promise): Promise; @@ -28,10 +27,6 @@ declare global { } } -export function arrayContainsAll(arr: T[], target: T[]) { - return target.every((v) => arr.includes(v)); -} - /* https://stackoverflow.com/a/50636286 */ export function arrayPartition(array: T[], filter: (elem: T) => boolean): [T[], T[]] { const pass: T[] = [], @@ -86,10 +81,6 @@ export function arrayIntersect(this: T[], other: T[]): T[] { } // register extensions -if (!Array.prototype.containsAll) - Array.prototype.containsAll = function (this: T[], target: T[]) { - return arrayContainsAll(this, target); - }; if (!Array.prototype.partition) Array.prototype.partition = function (this: T[], filter: (elem: T) => boolean) { return arrayPartition(this, filter);