TMIJS API TWITCH (Command !setGame ou !setTitle)

Bonsoir !

Je me suis renseigné sur comment mettre en place une commande de changement de jeu et de titre avec l’api tmijs et il montrait un moyen simple de communiquer avec l’api twitch directement via leur api mais malheureusement cette option n’est plus disponible dans les nouvelles version et j’aimerais savoir si il y aurait un autre moyen pour faire ça que de faire les requêtes manuellement étant assez nul en ça s’il vous plait.

Dans l’attente de votre retour, je vous souhaite une agréable journée.

Sounds like tmi.js (the libary) removed the API call parts of their library.

So either setup the calls to be done manually, or use a second library for making API calls.

connaitrais-tu une api capable de faire des appels à l’api twitch?

curl can make API calls if thats what you mean and curl exists in all languages

Merci pour l’aide mais j’ai un problème avec mon code. Il s’arrête juste avant le Request.get et je ne comprends pas pourquoi

Your First requests.get has no headers, so no clientID or token.

So it does res.statsuCode === 200 on line 6 ish

ahhh oui désolé, j’avais pas vu dans la doc qui demandait l’header mais là j’ai un autre problème, le code se répète deux fois et le changeGame est toujours undefined

Modify channel needs to be a PATCH not a PUT

Additionally the data needs to be a JSON Body for the game_id not query string

Ici je ne veux changer le jeu par rapport au game id mais par rapport au game_name, est-ce donc obligatoire d’utiliser le game_id?

For modify channel information the game_id is required not the game name

et comment je peux faire pour faire la commande !setgame League of Legends par exemple? J’assigne à league of legends un game_id ?

Get Games

will let you convert a game name to a game ID

Ok donc du coup j’ai fais ça pour récupérer le nom du jeu, est-ce correct? Si c’est le cas que dois-je faire ensuite pour convertir le nom du jeu en id? image

The API should return a JSON object with the ID present.

So the ID in the repsonse is the ID you need for the modify channel endpoint

So

https://api.twitch.tv/helix/games?name=fortnite

returns

{
  "data": [
    {
      "box_art_url": "https://static-cdn.jtvnw.net/ttv-boxart/Fortnite-52x72.jpg",
      "id": "33214",
      "name": "Fortnite"
    }
  ]
}

So the game_id to pass to modify channel is 33214

Oui j’ai vu la même chose dans l’exemple sur le site de twitch mais je ne comprends pas comment récupérer l’id dans la réponse de la requête https

pasrse the response from the HTTPS request into a Variable for your program to use

Then navigate the object and obtain the ID

Should be at

resp.data[0].id

Depending how your lnagauge parses JSON’s into varaibles

donc si j’ai bien compris, ça doit être quelque chose comme ça, et dans la condition qui return 200, je return l’id image

Looks like the _body will contain the body of the response, so parse that to JSON and away you go

Re !! Désolé encore de vous dérangez mais est-ce correct cette fois-ci? image

seems good give it a go only way to know for sure