Trinitui / AndrewBot

AndrewBot is a reactive bot developed for use in Discord Servers. WARNING: It's almost all inside jokes.
2 stars 1 forks source link

search yt for toh clips #37

Closed Trinitui closed 3 years ago

Trinitui commented 3 years ago

"toh flip swing"

youtube.com/v/abc123

Trinitui commented 3 years ago
 // X. This gets a toh result when the user asks for one, using !toh *
  if (msgContent.startsWith("!toh")) {
    let q = msg.content;
    //search yt for toh+searchterm
    axios
      .get(
        `https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&q=${q}&key=${YOUTUBE_APIKEY}`
      )
      .then((response) => {
        //send output to channel
        let vid = response.data.items[0].id.videoId;
        msg.channel.send(`https://www.youtube.com/watch?v=${vid}`);
      })
      .catch((error) => {
        console.log(error);
      });
  }
Trinitui commented 3 years ago

This has been done as well, and is actually pending refactor in issue #39