/
EventSubChannelRaidEvent.ts
83 lines (72 loc) · 2.24 KB
/
EventSubChannelRaidEvent.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { Enumerable } from '@d-fischer/shared-utils';
import type { ApiClient, HelixUser } from '@twurple/api';
import { checkRelationAssertion, DataObject, rawDataSymbol, rtfm } from '@twurple/common';
import { type EventSubChannelRaidEventData } from './EventSubChannelRaidEvent.external';
/**
* An EventSub event representing a broadcaster raiding another broadcaster.
*/
@rtfm<EventSubChannelRaidEvent>('eventsub-base', 'EventSubChannelRaidEvent', 'raidedBroadcasterId')
export class EventSubChannelRaidEvent extends DataObject<EventSubChannelRaidEventData> {
/** @internal */ @Enumerable(false) private readonly _client: ApiClient;
/** @internal */
constructor(data: EventSubChannelRaidEventData, client: ApiClient) {
super(data);
this._client = client;
}
/**
* The ID of the raiding broadcaster.
*/
get raidingBroadcasterId(): string {
return this[rawDataSymbol].from_broadcaster_user_id;
}
/**
* The name of the raiding broadcaster.
*/
get raidingBroadcasterName(): string {
return this[rawDataSymbol].from_broadcaster_user_login;
}
/**
* The display name of the raiding broadcaster.
*/
get raidingBroadcasterDisplayName(): string {
return this[rawDataSymbol].from_broadcaster_user_name;
}
/**
* Gets more information about the raiding broadcaster.
*/
async getRaidingBroadcaster(): Promise<HelixUser> {
return checkRelationAssertion(
await this._client.users.getUserById(this[rawDataSymbol].from_broadcaster_user_id),
);
}
/**
* The ID of the raided broadcaster.
*/
get raidedBroadcasterId(): string {
return this[rawDataSymbol].to_broadcaster_user_id;
}
/**
* The name of the raided broadcaster.
*/
get raidedBroadcasterName(): string {
return this[rawDataSymbol].to_broadcaster_user_login;
}
/**
* The display name of the raided broadcaster.
*/
get raidedBroadcasterDisplayName(): string {
return this[rawDataSymbol].to_broadcaster_user_name;
}
/**
* Gets more information about the raided broadcaster.
*/
async getRaidedBroadcaster(): Promise<HelixUser> {
return checkRelationAssertion(await this._client.users.getUserById(this[rawDataSymbol].to_broadcaster_user_id));
}
/**
* The amount of viewers in the raid.
*/
get viewers(): number {
return this[rawDataSymbol].viewers;
}
}