mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-17 02:29:10 +00:00
add tests; resync files, forgot where i was.
This commit is contained in:
parent
6b36b1d5f2
commit
1a794e2d7e
30 changed files with 3654 additions and 534 deletions
36
services/discord/restFetcher.js
Normal file
36
services/discord/restFetcher.js
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue