Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Get Moderated Channels * fix typo --------- Co-authored-by: Daniel Fischer <daniel@d-fischer.dev>
- Loading branch information
1 parent
857b05f
commit 9b94eee
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
packages/api/src/endpoints/moderation/HelixModeratedChannel.ts
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,57 @@ | ||
import { Enumerable } from '@d-fischer/shared-utils'; | ||
import { checkRelationAssertion, DataObject, rawDataSymbol, rtfm } from '@twurple/common'; | ||
import type { BaseApiClient } from '../../client/BaseApiClient'; | ||
import type { HelixModeratedChannelData } from '../../interfaces/endpoints/moderation.external'; | ||
import type { HelixUser } from '../user/HelixUser'; | ||
import type { HelixChannel } from '../channel/HelixChannel'; | ||
|
||
/** | ||
* A reference to a Twitch channel where a user is a moderator. | ||
*/ | ||
@rtfm<HelixModeratedChannel>('api', 'HelixModeratedChannel', 'id') | ||
export class HelixModeratedChannel extends DataObject<HelixModeratedChannelData> { | ||
/** @internal */ @Enumerable(false) private readonly _client: BaseApiClient; | ||
|
||
/** @internal */ | ||
constructor(data: HelixModeratedChannelData, client: BaseApiClient) { | ||
super(data); | ||
this._client = client; | ||
} | ||
|
||
/** | ||
* The ID of the channel. | ||
*/ | ||
get id(): string { | ||
return this[rawDataSymbol].broadcaster_id; | ||
} | ||
|
||
/** | ||
* The name of the channel. | ||
*/ | ||
get name(): string { | ||
return this[rawDataSymbol].broadcaster_login; | ||
} | ||
|
||
/** | ||
* The display name of the channel. | ||
*/ | ||
get displayName(): string { | ||
return this[rawDataSymbol].broadcaster_name; | ||
} | ||
|
||
/** | ||
* Gets more information about the channel. | ||
*/ | ||
async getChannel(): Promise<HelixChannel> { | ||
return checkRelationAssertion( | ||
await this._client.channels.getChannelInfoById(this[rawDataSymbol].broadcaster_id), | ||
); | ||
} | ||
|
||
/** | ||
* Gets more information about the broadcaster of the channel. | ||
*/ | ||
async getBroadcaster(): Promise<HelixUser> { | ||
return checkRelationAssertion(await this._client.users.getUserById(this[rawDataSymbol].broadcaster_id)); | ||
} | ||
} |
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