Skip to content

Latest commit

 

History

History
61 lines (53 loc) · 1.9 KB

README.md

File metadata and controls

61 lines (53 loc) · 1.9 KB

Nest Logo

Twitch API/Chat/PubSub with Twurple NestJS module

NPM Version Package License Publish Package to npmjs


Twurple Module

Twurple for NestJS Framework

Install dependencies

yarn add @the-software-compagny/nestjs_module_twurple

Instanciate

// app.module.ts
import { TwurpleModule, TwurpleOptions } from '@the-software-compagny/nestjs_module_twurple'

TwurpleModule.forRootAsync({
  imports: [ConfigModule],
  inject: [ConfigService],
  useFactory: async (config: ConfigService) => ({
    config: config.get<TwurpleOptions>('twurple.options'),
  }),
})

Usage

// twitch.service.ts
import { FactorydriveService } from '@the-software-compagny/nestjs_module_factorydrive'

@Injectable()
export class FileStorageService {
  public constructor(
    @InjectTwurpleApi() private readonly twurpleApi: ApiClient,
    @InjectTwurpleChat() private readonly twurpleChat: ChatClient,
    @InjectTwurplePubsub() private readonly twurplePubSub: PubSubClient,
  ) {
    // ...

    this.twurpleChat.onMessage(async (channel, user, message) => {
      if (message === '!ping') {
        this.twurpleChat.say(channel, 'Pong!')
      }
    })
    
    // ...
  }
}