Use the prefix command "%search" followed by a term to search Twitch. Enjoy!
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let text = context.params.event.content.split(' ').slice(1).join(' ');
let result = `https://www.twitch.tv/search?term=${text}`;
//embed part
if (context.params.event.content.startsWith(`%search`)) {
await lib.discord.channels['@0.1.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
tts: false,
components: [
{
type: 1,
components: [
{
style: 5,
label: `TWITCH`,
url: `https://www.twitch.tv/search?term=${text}`,
disabled: false,
emoji: {
id: null,
name: `π―`,
},
type: 2,
},
],
},
],
channel_id: `${context.params.event.channel_id}`,
content: `yo here is your results for **${text}**`,
});
}