Files
bot_Laytho/utils/getRewardID.js
2023-05-11 00:37:16 +02:00

14 lines
553 B
JavaScript

const axios = require('axios')
module.exports = async function (client_id, access_token, broadcaster_id, reward_name) {
return await axios.get(`https://api.twitch.tv/helix/channel_points/custom_rewards?broadcaster_id=${broadcaster_id}`, {
headers: {
'Authorization': `Bearer ${access_token}`,
'Client-Id': client_id
}
}).then(response => {
//console.log(response.data)
let reward = response.data.data.find(reward => reward.title === reward_name)
return reward.id
}).catch(error => { console.log(error.response.data) })
}