/
EventSubUserUpdateEvent.ts
73 lines (64 loc) · 2 KB
/
EventSubUserUpdateEvent.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
import { Enumerable } from '@d-fischer/shared-utils';
import type { ApiClient, HelixUser } from '@twurple/api';
import { checkRelationAssertion, DataObject, rawDataSymbol, rtfm } from '@twurple/common';
import { type EventSubUserUpdateEventData } from './EventSubUserUpdateEvent.external';
/**
* An EventSub event representing updating their account details.
*/
@rtfm<EventSubUserUpdateEvent>('eventsub-base', 'EventSubUserUpdateEvent', 'userId')
export class EventSubUserUpdateEvent extends DataObject<EventSubUserUpdateEventData> {
/** @internal */ @Enumerable(false) private readonly _client: ApiClient;
/** @internal */
constructor(data: EventSubUserUpdateEventData, client: ApiClient) {
super(data);
this._client = client;
}
/**
* The ID of the user.
*/
get userId(): string {
return this[rawDataSymbol].user_id;
}
/**
* The name of the user.
*/
get userName(): string {
return this[rawDataSymbol].user_login;
}
/**
* The display name of the user.
*/
get userDisplayName(): string {
return this[rawDataSymbol].user_name;
}
/**
* The user's profile description.
*/
get userDescription(): string {
return this[rawDataSymbol].description;
}
/**
* The user's email address.
*
* This is `null` if you are not authorized to read the email address,
* i.e. you have never successfully requested the scope `user:read:email` from the user.
*/
get userEmail(): string | null {
return this[rawDataSymbol].email ?? null;
}
/**
* Whether the user's email address has been verified by Twitch.
*
* This is `null` if you are not authorized to read the email address,
* i.e. you have never successfully requested the scope `user:read:email` from the user.
*/
get userEmailIsVerified(): boolean | null {
return this[rawDataSymbol].email ? this[rawDataSymbol].email_verified : null;
}
/**
* Gets more information about the user.
*/
async getUser(): Promise<HelixUser> {
return checkRelationAssertion(await this._client.users.getUserById(this[rawDataSymbol].user_id));
}
}