harmony/src/test/index.ts

34 lines
990 B
TypeScript
Raw Normal View History

import { Client } from '../models/client.ts'
import { Guild } from '../structures/guild.ts'
import { GatewayIntents } from '../types/gatewayTypes.ts'
import { TOKEN } from './config.ts'
import * as cache from '../models/cache.ts'
2020-10-25 08:02:24 +00:00
import { Member } from '../structures/member.ts'
const bot = new Client()
bot.connect(TOKEN, [GatewayIntents.GUILD_MEMBERS, GatewayIntents.GUILD_PRESENCES, GatewayIntents.GUILD_MESSAGES])
const member = <Member> await Member.autoInit(bot, {
cacheName: 'member',
endpoint: 'GUILD_MEMBER',
2020-10-25 08:20:11 +00:00
restURLfuncArgs: ['', '']
})
2020-10-25 08:18:32 +00:00
console.log('getted (cached) ' + member.nick)
setInterval(async () => {
//refreshed check
2020-10-25 08:18:32 +00:00
console.log('refreshed check: ' + member.nick)
//cached
2020-10-25 08:20:11 +00:00
console.log('cache: '+(<Member> cache.get('member', '')).nick)
}, 10000)
setInterval(async() => {
member.refresh(bot, {
cacheName: 'member',
endpoint: 'GUILD_MEMBER',
2020-10-25 08:20:11 +00:00
restURLfuncArgs: ['', '']
2020-10-25 00:15:33 +00:00
})
//refreshed
2020-10-25 08:18:32 +00:00
console.log('refreshed: ' + member.nick)
}, 20000)