Set your bot status to streaming and send a message to a Discord channel when you go live. Includes a button link to the stream in the message
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const discordChannel = 'ANNOUNCEMENT_CHANNEL_ID'; // Set this to the channel ID you want to send announcements to
await lib.discord.users['@0.1.2'].me.status.update({
activity_name: `Live on Twitch now! @${context.params.event.broadcaster_user_name}`,
activity_type: 'STREAMING',
url: `https://www.twitch.tv/${context.params.event.broadcaster_user_name}`,
status: 'DND'
});
await lib.discord.channels['@0.1.1'].messages.create({
"channel_id": discordChannel,
"content": "Hey @everyone! I'm live on Twitch! πΎ",
"tts": false,
"components": [
{
"type": 1,
"components": [
{
"style": 5,
"label": "Watch the Stream",
"url": `https://www.twitch.tv/${context.params.event.broadcaster_user_name}`,
"disabled": false,
"emoji": {
"id": null,
"name": "πΎ"
},
"type": 2
}
]
}
]
});