diff --git a/src/util/config/types/subconfigurations/limits/MessageLimits.ts b/src/util/config/types/subconfigurations/limits/MessageLimits.ts
index f61c0b65..50ea32d2 100644
--- a/src/util/config/types/subconfigurations/limits/MessageLimits.ts
+++ b/src/util/config/types/subconfigurations/limits/MessageLimits.ts
@@ -24,4 +24,5 @@ export class MessageLimits {
maxBulkDelete: number = 1000;
maxEmbedDownloadSize: number = 1024 * 1024 * 5;
maxPreloadCount: number = 100;
+ maxEmbeds: number = 20;
}
diff --git a/src/util/entities/EmbedCache.ts b/src/util/entities/EmbedCache.ts
index db1fbba6..a9ffd063 100644
--- a/src/util/entities/EmbedCache.ts
+++ b/src/util/entities/EmbedCache.ts
@@ -29,4 +29,11 @@ export class EmbedCache extends BaseClass {
@Column({ type: "simple-json" })
embed: Embed;
+
+ // TODO: store all returned embed objects from a handler
+ // @Column({ type: "simple-json" })
+ // embeds: Embed[];
+
+ @Column({ name: "created_at", type: "timestamp with time zone" })
+ createdAt: Date;
}
diff --git a/src/util/migration/postgres/1772404321402-EmbedCacheCreatedAt.ts b/src/util/migration/postgres/1772404321402-EmbedCacheCreatedAt.ts
new file mode 100644
index 00000000..bf845ff7
--- /dev/null
+++ b/src/util/migration/postgres/1772404321402-EmbedCacheCreatedAt.ts
@@ -0,0 +1,13 @@
+import { MigrationInterface, QueryRunner } from "typeorm";
+
+export class EmbedCacheCreatedAt1772404321402 implements MigrationInterface {
+ name = "EmbedCacheCreatedAt1772404321402";
+
+ public async up(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query(`ALTER TABLE "embed_cache" ADD "created_at" timestamp with time zone DEFAULT now();`);
+ }
+
+ public async down(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query(`ALTER TABLE "embed_cache" DROP COLUMN "created_at"`);
+ }
+}
diff --git a/src/util/util/extensions/Array.ts b/src/util/util/extensions/Array.ts
index bb5f3362..61cf469b 100644
--- a/src/util/util/extensions/Array.ts
+++ b/src/util/util/extensions/Array.ts
@@ -42,3 +42,16 @@ export function arrayDistinctBy<T, M>(array: T[], selector: (elem: T) => M): T[]
return true;
});
}
+
+export function arrayGroupBy<T, M>(array: T[], selector: (elem: T) => M): Map<M, T[]> {
+ const map = new Map<M, T[]>();
+
+ array.forEach((item) => {
+ const mappedValue = selector(item);
+ const existing = map.get(mappedValue);
+ if (existing) existing.push(item);
+ else map.set(mappedValue, [item]);
+ });
+
+ return map;
+}
|