import { NodeCG } from "nodecg-types/types/server" ; import { Result , emptySuccess , success , ServiceBundle , Logger } from "nodecg-io-core" ; import { TwitchChatServiceClient } from "./twitchClient" ; import { getTokenInfo , TwitchServiceConfig } from "nodecg-io-twitch-auth" ; export { TwitchChatServiceClient } from "./twitchClient" ; module . exports = ( nodecg ) => { new TwitchService ( nodecg , "twitch-chat" , __dirname , "../twitch-schema.json" ) . register ( ) ; } ; class TwitchService extends ServiceBundle < TwitchServiceConfig , TwitchChatServiceClient > { async validateConfig ( config ) { await getTokenInfo ( config ) ; return emptySuccess ( ) ; } async createClient ( config , logger ) { logger . info ( "Connecting to twitch chat..." ) ; const client = await TwitchChatServiceClient . createClient ( config ) ; logger . info ( "Successfully connected to twitch." ) ; return success ( client ) ; } stopClient ( client , logger ) { client . quit ( ) . then ( ( ) => logger . info ( "Successfully stopped twitch client." ) ) ; } removeHandlers ( client ) { client . removeListener ( ) ; } }