Search YouTube with this slash command: /search <term> . Create slash command with one string option! The bot will post the corresponding youtube link in an embed with a button.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let text = context.params.event.data.options[0].value;
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: `YT`,
url: `https://www.youtube.com/results?search_query=${text}`,
disabled: false,
emoji: {
id: null,
name: `🎯`,
},
type: 2,
},
],
},
],
embeds: [
{
type: 'rich',
title: `YouTube`,
description: `Search result for: ${text}`,
color: 0xff0000,
thumbnail: {
url: `https://acegif.com/wp-content/uploads/2021/4fh5wi/pepefrg-49.gif`,
height: 20,
width: 20,
},
},
],
});