diff --git a/.gitignore b/.gitignore index df7c588..86ddba1 100644 --- a/.gitignore +++ b/.gitignore @@ -110,3 +110,5 @@ yarn.lock # PRIVACY XDDDD src/test/config.ts .vscode + +src/test/ \ No newline at end of file diff --git a/src/structures/base.ts b/src/structures/base.ts index 4692a5c..b156aa2 100644 --- a/src/structures/base.ts +++ b/src/structures/base.ts @@ -23,12 +23,12 @@ export class Base { init.cacheName, init.restURLfuncArgs[0] ) - if (cached !== undefined && cached instanceof this) { + if (cached !== undefined) { return cached } } - this.restFunc = endpoint.filter(v => v.name !== init.endpoint) + this.restFunc = endpoint.filter(v => v.name === init.endpoint) const resp = await fetch(this.restFunc[0](init.restURLfuncArgs), { headers: { @@ -37,7 +37,10 @@ export class Base { }) const jsonParsed = await resp.json() - cache.set(init.cacheName, this.restFunc[0](init.restURLfuncArgs), jsonParsed) + + cache.set(init.cacheName, init.restURLfuncArgs[0], jsonParsed) + + return jsonParsed } static async refresh (client: Client, target: any, init: IInit) { diff --git a/src/test/index.ts b/src/test/index.ts index 0d21b9d..e2cf681 100644 --- a/src/test/index.ts +++ b/src/test/index.ts @@ -7,9 +7,17 @@ const bot = new Client() bot.connect(TOKEN, [GatewayIntents.GUILD_MESSAGES]) -Guild.autoInit(bot, '').then(a => console.log(a)) +Guild.autoInit(bot, { + cacheName: 'guild', + endpoint: 'GUILD', + restURLfuncArgs: [''] +}).then((a) => console.log(a)) setTimeout(async () => { - const result = Guild.autoInit(bot, '') + const result = Guild.autoInit(bot, { + cacheName: 'guild', + endpoint: 'GUILD', + restURLfuncArgs: [''] + }) console.log(result) -}, 30000) +}, 30000) \ No newline at end of file