Edited Base and Tested
This commit is contained in:
parent
251e4c482d
commit
8cf02d2ba4
3 changed files with 19 additions and 6 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -110,3 +110,5 @@ yarn.lock
|
||||||
# PRIVACY XDDDD
|
# PRIVACY XDDDD
|
||||||
src/test/config.ts
|
src/test/config.ts
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
|
src/test/
|
|
@ -23,12 +23,12 @@ export class Base {
|
||||||
init.cacheName,
|
init.cacheName,
|
||||||
init.restURLfuncArgs[0]
|
init.restURLfuncArgs[0]
|
||||||
)
|
)
|
||||||
if (cached !== undefined && cached instanceof this) {
|
if (cached !== undefined) {
|
||||||
return cached
|
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), {
|
const resp = await fetch(this.restFunc[0](init.restURLfuncArgs), {
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -37,7 +37,10 @@ export class Base {
|
||||||
})
|
})
|
||||||
|
|
||||||
const jsonParsed = await resp.json()
|
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) {
|
static async refresh (client: Client, target: any, init: IInit) {
|
||||||
|
|
|
@ -7,9 +7,17 @@ const bot = new Client()
|
||||||
|
|
||||||
bot.connect(TOKEN, [GatewayIntents.GUILD_MESSAGES])
|
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 () => {
|
setTimeout(async () => {
|
||||||
const result = Guild.autoInit(bot, '')
|
const result = Guild.autoInit(bot, {
|
||||||
|
cacheName: 'guild',
|
||||||
|
endpoint: 'GUILD',
|
||||||
|
restURLfuncArgs: ['']
|
||||||
|
})
|
||||||
console.log(result)
|
console.log(result)
|
||||||
}, 30000)
|
}, 30000)
|
Loading…
Reference in a new issue