Hambergo / 9kmmrbot

MIT License
104 stars 29 forks source link

Migrate from Twitch API v5 to New Twitch API #14

Closed Hambergo closed 3 years ago

Hambergo commented 5 years ago

Twitch API v5 is currently deprecated with no scheduled removal date. If the New Twitch API is already supporting our usage of the api, we need to update the code to use the New Twitch API

tverghis commented 5 years ago

I ran a search for files using containing api.twitch.tv:

9kmmrbot $ grep -rnw 'api.twitch' --exclude-dir={node_modules,data}
lib/commands/Score.js:17:               let stream = await util.fetch('https://api.twitch.tv/kraken/streams/' + userstate['room-id'], { headers: util.twitchAPIHeaders }).then(res => res.json())
lib/commands/Score.js:21:               let videos = await util.fetch(`https://api.twitch.tv/kraken/channels/${userstate['room-id']}/videos?${querystring.stringify({ 'broadcast_type': 'archive' })}`, { headers: util.twitchAPIHeaders }).then(res => res.json())
lib/commands/Moderation.js:161:                                 return util.fetch('https://api.twitch.tv/kraken/users?login=' + split[2], { headers: util.twitchAPIHeaders }).then(res => res.json()).then(async json => {
lib/commands/Moderation.js:185:                                 return util.fetch('https://api.twitch.tv/kraken/users?login=' + split[2], { headers: util.twitchAPIHeaders }).then(res => res.json()).then(async json => {
lib/commands/Moderation.js:239:                                         return util.fetch('https://api.twitch.tv/kraken/users?login=' + split[2], { headers: util.twitchAPIHeaders }).then(res => res.json()).then(async json => {
lib/commands/Moderation.js:253:                                         return util.fetch('https://api.twitch.tv/kraken/users?login=' + split[2], { headers: util.twitchAPIHeaders }).then(res => res.json()).then(async json => {
lib/twitchApi.js:13:const helixBaseURI = 'https://api.twitch.tv/helix'

There are 6 instances that need to be changed:

Score.js

Moderation.js

Hambergo commented 5 years ago

Commits a5ca268ba639959ae3774139b6e61cce2b49b817 and 6425241676486b199834701e1e49a963ed8c5b43 fixes the score command, and added GetUserInfoByLogin(login) to twitchApi.js to use in moderation.js

moderation.js wasn't changed yet because pr #33 being worked on