11const GraphQL = require ( "./graphql" ) ;
22
33const Twitch = {
4+ /**
5+ * Set the Twitch Client ID for API requests
6+ * @param {string } ClientID - The Twitch Client ID
7+ */
48 SetClientID ( ClientID ) {
59 GraphQL . ClientID = ClientID ;
610 } ,
11+ /**
12+ * Get user information by login name
13+ * @param {string } login - The Twitch username
14+ * @param {Object } [variables={}] - Additional query variables
15+ * @returns {Promise<Object> } User data
16+ */
717 GetUser ( login , variables = { } ) {
818 variables = { ...variables , login} ;
919 return GraphQL . SendQuery ( "GET_USER" , variables ) ;
1020 } ,
21+ /**
22+ * Get top streams on Twitch
23+ * @deprecated Currently unavailable - Twitch has changed their operation hashes
24+ * @param {number } [amount=25] - Number of streams to fetch
25+ * @param {Object } [variables={}] - Additional query variables
26+ * @returns {Promise<Object> } Top streams data
27+ */
1128 GetTopStreams ( amount = 25 , variables = { } ) {
29+ console . warn ( "DEPRECATED: GetTopStreams is currently unavailable. Twitch has changed their operation hashes and this function needs to be updated." ) ;
1230 variables = {
1331 limit : amount ,
1432 platformType : "all" ,
@@ -17,6 +35,12 @@ const Twitch = {
1735 } ;
1836 return GraphQL . SendQuery ( "AllChannels_InternationalSection" , variables , true ) ;
1937 } ,
38+ /**
39+ * Get videos/VODs from a channel
40+ * @param {string } login - The channel login name
41+ * @param {Object } [variables={}] - Additional query variables (broadcastType, limit, videoSort, etc.)
42+ * @returns {Promise<Object> } Videos data
43+ */
2044 GetVideos ( login , variables = { } ) {
2145 let opts = {
2246 broadcastType : "ARCHIVE" ,
@@ -27,6 +51,12 @@ const Twitch = {
2751 }
2852 return GraphQL . SendQuery ( "FilterableVideoTower_Videos" , opts , true ) ;
2953 } ,
54+ /**
55+ * Get playback access token for a VOD
56+ * @param {string } vodID - The VOD ID
57+ * @param {Object } [variables={}] - Additional query variables
58+ * @returns {Promise<Object> } Playback access token data
59+ */
3060 GetPlaybackAccessToken ( vodID , variables = { } ) {
3161 let opts = {
3262 isLive : false ,
@@ -38,13 +68,26 @@ const Twitch = {
3868 } ;
3969 return GraphQL . SendQuery ( "PlaybackAccessToken" , opts , true ) ;
4070 } ,
71+ /**
72+ * Get video moments/highlights for a VOD
73+ * @param {string } vodID - The VOD ID
74+ * @param {Object } [variables={}] - Additional query variables
75+ * @returns {Promise<Object> } Video moments data
76+ */
4177 GetVideoMoments ( vodID , variables = { } ) {
4278 let opts = {
4379 videoId : vodID ,
4480 ...variables
4581 } ;
4682 return GraphQL . SendQuery ( "VideoPreviewCard__VideoMoments" , opts , true ) ;
4783 } ,
84+ /**
85+ * Get metadata for a specific video
86+ * @param {string } channelLogin - The channel login name
87+ * @param {string } vodID - The VOD ID
88+ * @param {Object } [variables={}] - Additional query variables
89+ * @returns {Promise<Object> } Video metadata
90+ */
4891 GetVideoMetadata ( channelLogin , vodID , variables = { } ) {
4992 let opts = {
5093 channelLogin,
@@ -53,21 +96,42 @@ const Twitch = {
5396 } ;
5497 return GraphQL . SendQuery ( "VideoMetadata" , opts , true ) ;
5598 } ,
99+ /**
100+ * Get category tags for a game
101+ * @deprecated Currently unavailable - Twitch has changed their operation hashes
102+ * @param {string } gameName - The name of the game
103+ * @param {Object } [variables={}] - Additional query variables
104+ * @returns {Promise<Object> } Category tags data
105+ */
56106 GetGameCategoryTags ( gameName , variables = { } ) {
107+ console . warn ( "DEPRECATED: GetGameCategoryTags is currently unavailable. Twitch has changed their operation hashes and this function needs to be updated." ) ;
57108 let opts = {
58109 gameName,
59110 tagType : "CONTENT" ,
60111 ...variables
61112 } ;
62113 return GraphQL . SendQuery ( "CategoryTags" , opts , true ) ;
63114 } ,
115+ /**
116+ * Get chat messages for a clip
117+ * @param {string } clipSlug - The clip slug/ID
118+ * @param {Object } [variables={}] - Additional query variables
119+ * @returns {Promise<Object> } Chat clip data
120+ */
64121 GetChatClip ( clipSlug , variables = { } ) {
65122 let opts = {
66123 clipSlug,
67124 ...variables
68125 } ;
69126 return GraphQL . SendQuery ( "ChatClip" , opts , true ) ;
70127 } ,
128+ /**
129+ * Get clips for a user
130+ * @param {string } login - The user login name
131+ * @param {string } [filter="ALL_TIME"] - Time filter (ALL_TIME, LAST_DAY, LAST_WEEK, LAST_MONTH)
132+ * @param {number } [limit=20] - Number of clips to fetch
133+ * @returns {Promise<Object> } User clips data
134+ */
71135 GetClipsCardsUser ( login , filter = "ALL_TIME" , limit = 20 ) {
72136 const variables = {
73137 login : login ,
@@ -80,18 +144,36 @@ const Twitch = {
80144 } ;
81145 return GraphQL . SendQuery ( "ClipsCards__User" , variables , true ) ;
82146 } ,
147+ /**
148+ * Get metadata for a specific clip
149+ * @param {string } clipSlug - The clip slug/ID
150+ * @returns {Promise<Object> } Clip metadata
151+ */
83152 GetClipMetadata ( clipSlug ) {
84153 const variables = {
85154 clipSlug
86155 } ;
87156 return GraphQL . SendQuery ( "ClipMetadata" , variables , true ) ;
88157 } ,
158+ /**
159+ * Get the render status of a shared clip
160+ * @param {string } slug - The clip slug/ID
161+ * @returns {Promise<Object> } Clip render status data
162+ */
89163 GetShareClipRenderStatus ( slug ) {
90164 const variables = {
91165 slug
92166 } ;
93167 return GraphQL . SendQuery ( "ShareClipRenderStatus" , variables , true ) ;
94168 } ,
169+ /**
170+ * Internal method to send a custom GraphQL query
171+ * @private
172+ * @param {string } QueryName - The name of the query
173+ * @param {Object|null } [variables=null] - Query variables
174+ * @param {boolean } [preset=false] - Whether to use a preset query
175+ * @returns {Promise<Object> } Query result
176+ */
95177 _SendQuery ( QueryName , variables = null , preset = false ) {
96178 return GraphQL . SendQuery ( QueryName , variables , preset ) ;
97179 }
0 commit comments