Command search a twitch channel and see if they are LIVE!!! ..... Make sure you make a slash command on the builder like this picture! π https://cdn.discordapp.com/attachments/986081321094881290/988634008936136755/unknown.png
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
//make slash command on builder --> https://autocode.com/tools/discord/command-builder/
//make command like this --> https://cdn.discordapp.com/attachments/986081321094881290/988634008936136755/unknown.png
try {
let channel_name = context.params.event.data.options[0].value; // slash command user response
console.log(channel_name);
let result = await lib.twitch.search['@1.0.0'].channels.list({
//SEARCH TWITCH
query: `${channel_name}`, // IN LOGS THIS IS UNDER `VALUE`
first: 1, //ONLY WANT ONE PERSON WITHIN RESULTS
live_only: false,
});
console.log(result); //PUT INFO ON TOOLS
let display_name = result.data[0].display_name;
let title = result.data[0].title;
let game_name = result.data[0].game_name;
let live = result.data[0].is_live;
if (live) {
await lib.discord.channels['@0.3.2'].messages.create({
//send info if live
channel_id: context.params.event.channel_id,
content: `**${display_name} IS LIVE!\n${title} \nGO LOOK! https://www.twitch.tv/${display_name} | Streaming ${game_name} !!**`,
});
} else if (!live) {
// ! == β
await lib.discord.channels['@0.3.2'].messages.create({
//send info if not live
channel_id: context.params.event.channel_id,
content: `Sorry, ${display_name} is not live at the moment. `,
});
}
} catch (e) {
// catches the errors
await lib.discord.channels['@0.3.2'].messages.create({
//send info if there's an error, timeout, breaks and ect....
channel_id: context.params.event.channel_id,
content: `${e}jbvghjklkjhg ERROR!`, // WRITE A BETTER ERROR MESSAGE HERE BUT KEEP e
});
}