-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
RaidEventHandler
event sub to bot
- Loading branch information
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { EventSubChannelRaidEvent } from '@twurple/eventsub-base'; | ||
import { inject, injectable } from 'inversify'; | ||
import winston from 'winston'; | ||
import InjectionTypes from '../../dependency-management/types'; | ||
import { FollowEvent, RaidEvent } from '../../database'; | ||
|
||
@injectable() | ||
export default class RaidEventHandler { | ||
constructor( | ||
@inject(InjectionTypes.Logger) private logger: winston.Logger, | ||
) { | ||
} | ||
|
||
/** | ||
* Records the event of a user being added as a moderator to the channel | ||
* @param event Raid Event | ||
*/ | ||
async raid(event: EventSubChannelRaidEvent): Promise<void> { | ||
return RaidEvent | ||
.raid(event) | ||
.catch((reason: any) => { | ||
this.logger.error(`Unable to store Raid event in DB >> ${reason}`); | ||
}) | ||
.then(() => { | ||
this.logger.info(`${event.raidingBroadcasterDisplayName} raided ${event.raidedBroadcasterDisplayName} on ${(new Date()).toDateString()}`); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters