add tests; resync files, forgot where i was.

This commit is contained in:
41666 2019-03-29 13:59:57 -05:00
parent 6b36b1d5f2
commit 1a794e2d7e
No known key found for this signature in database
GPG key ID: BC51D07640DC10AF
30 changed files with 3654 additions and 534 deletions

View file

@ -0,0 +1,36 @@
// @flow
import type { IFetcher } from './types'
import type DiscordSvc from '../discord'
import type ErisClient, { User, Member, Guild } from 'eris'
export default class BotFetcher implements IFetcher {
ctx: DiscordSvc
client: ErisClient
constructor (ctx: DiscordSvc) {
this.ctx = ctx
this.client = ctx.client
}
getUser = async (id: string): Promise<?User> => {
try {
return await this.client.getRESTUser(id)
} catch (e) {
return null
}
}
getMember = async (server: string, user: string): Promise<?Member> => {
try {
return await this.client.getRESTGuildMember(server, user)
} catch (e) {
return null
}
}
getGuild = async (server: string): Promise<?Guild> => {
try {
return await this.client.getRESTGuild(server)
} catch (e) {
return null
}
}
}