Fix token twitch non refresh pour notifications
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "bot_tamiseur",
|
"name": "bot_tamiseur",
|
||||||
"description": "Listen to music and use fun commands with your friends!",
|
"description": "Listen to music and use fun commands with your friends!",
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Zachary Guénot"
|
"name": "Zachary Guénot"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle notification messages
|
// Handle notification messages
|
||||||
else if (data.metadata.message_type === 'notification') Twitch.notification(client_id, channel_access_token, data, guild)
|
else if (data.metadata.message_type === 'notification') Twitch.notification(client_id, client_secret, channel_access_token, data, guild)
|
||||||
|
|
||||||
} catch (error) { console.error(chalk.magenta(`[Twitch] {${guild.name}} ` + error)) } } })
|
} catch (error) { console.error(chalk.magenta(`[Twitch] {${guild.name}} ` + error)) } } })
|
||||||
.on('error', error => console.error(chalk.magenta(`[Twitch] {${guild.name}} ` + error)))
|
.on('error', error => console.error(chalk.magenta(`[Twitch] {${guild.name}} ` + error)))
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export async function getUserInfo (client_id: string, access_token: string, type
|
|||||||
}).catch(error => { console.error(error.response.data) })
|
}).catch(error => { console.error(error.response.data) })
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function notification (client_id: string, channel_access_token: string, data: NotificationData, guild: Guild) {
|
export async function notification (client_id: string, client_secret: string, channel_access_token: string, data: NotificationData, guild: Guild) {
|
||||||
if (!guild) return console.log(chalk.magenta('[Twitch] Can\'t find guild !'))
|
if (!guild) return console.log(chalk.magenta('[Twitch] Can\'t find guild !'))
|
||||||
let { subscription, event } = data.payload
|
let { subscription, event } = data.payload
|
||||||
|
|
||||||
@@ -111,6 +111,10 @@ export async function notification (client_id: string, channel_access_token: str
|
|||||||
|
|
||||||
let liveMessageInterval
|
let liveMessageInterval
|
||||||
|
|
||||||
|
// Check if the channel access token is still valid before connecting
|
||||||
|
channel_access_token = await checkChannel(client_id, client_secret, channel_access_token, guild) as string
|
||||||
|
if (!channel_access_token) return console.log(chalk.magenta(`[Twitch] {${guild.name}} Can't refresh channel access token !`))
|
||||||
|
|
||||||
if (subscription.type === 'stream.online') {
|
if (subscription.type === 'stream.online') {
|
||||||
console.log(chalk.magenta(`[Twitch] {${guild.name}} Stream from ${event.broadcaster_user_name} is now online, sending Discord message...`))
|
console.log(chalk.magenta(`[Twitch] {${guild.name}} Stream from ${event.broadcaster_user_name} is now online, sending Discord message...`))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user