-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
84 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { NonEnumerable } from '../../../Toolkit/Decorators/NonEnumerable'; | ||
import TwitchClient from '../../../TwitchClient'; | ||
|
||
interface UserChatInfoGlobalBadgeData { | ||
id: string; | ||
version: string; | ||
} | ||
|
||
export interface UserChatInfoData { | ||
_id: string; | ||
login: string; | ||
display_name: string; | ||
color: string; | ||
is_verified_bot: boolean; | ||
is_known_bot: boolean; | ||
badges: UserChatInfoGlobalBadgeData[]; | ||
} | ||
|
||
export default class UserChatInfo { | ||
@NonEnumerable private readonly _client: TwitchClient; | ||
|
||
/** @private */ | ||
constructor(private readonly _data: UserChatInfoData, client: TwitchClient) { | ||
this._client = client; | ||
} | ||
|
||
get id() { | ||
return this._data._id; | ||
} | ||
|
||
async getUser() { | ||
return this._client.kraken.users.getUser(this._data._id); | ||
} | ||
|
||
get userName() { | ||
return this._data.login; | ||
} | ||
|
||
get displayName() { | ||
return this._data.display_name; | ||
} | ||
|
||
get color() { | ||
return this._data.color; | ||
} | ||
|
||
get isKnownBot() { | ||
return this._data.is_known_bot; | ||
} | ||
|
||
get isVerifiedBot() { | ||
return this._data.is_verified_bot; | ||
} | ||
|
||
get isAtLeastKnownBot() { | ||
return this._data.is_known_bot || this._data.is_verified_bot; | ||
} | ||
|
||
hasBadge(id: string) { | ||
return this._data.badges.some(badge => badge.id === id); | ||
} | ||
} |