Edited Base and Tested
This commit is contained in:
parent
251e4c482d
commit
8cf02d2ba4
|
@ -110,3 +110,5 @@ yarn.lock
|
|||
# PRIVACY XDDDD
|
||||
src/test/config.ts
|
||||
.vscode
|
||||
|
||||
src/test/
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue