loads of new commands, updates and bug fixes
diff --git a/src/utils/memory.ts b/src/utils/memory.ts
index 0cbf955..7e21fa9 100644
--- a/src/utils/memory.ts
+++ b/src/utils/memory.ts
@@ -1,22 +1,31 @@
-import readConfig from "./readConfig.js";
+import client from "./client.js";
class Memory {
memory: {};
constructor() {
this.memory = {};
+
+ setInterval(() => {
+ for (let guild in this.memory) {
+ if (this.memory[guild].updated + 15 * 60 * 1000 < Date.now()) {
+ delete this.memory[guild];
+ }
+ }
+ }, 1000 * 60 * 30)
}
async readGuildInfo(guild: string): Promise<object> {
if (!this.memory[guild]) {
- let guildData = await readConfig(guild);
+ let guildData = await client.database.read(guild);
this.memory[guild] = {
+ lastUpdated: Date.now(),
filters: guildData.filters,
logging: guildData.logging,
tickets: guildData.tickets,
- }; // TODO: REMOVE GUILD FROM MEMORY WHEN THESE UPDATE
- } // TODO: Add a "lastAccessed" prop, delete after 15 minutes
+ };
+ };
return this.memory[guild];
}
}
-export default Memory;
\ No newline at end of file
+export default Memory;