2022-09-27 16:45:50 -04:00
const { Constants } = require ( 'discord.js' ) ;
2022-03-10 20:30:03 -05:00
module . exports = {
name : 'kareoke' ,
2022-04-24 13:31:24 -04:00
description : 'Sing your least-favorite song with your favorite person, me!' ,
2022-09-27 16:45:50 -04:00
execute ( interaction , Discord , Client , bot ) {
const arg = interaction . options . data [ 0 ] . value ;
if ( arg == "help" ) { return interaction . reply ( { content : "Please pick out a song at https://www.karaoke-lyrics.net/\nThe command should look like\n/kareoke [link_here]" } ) ; }
2022-03-10 20:30:03 -05:00
const axios = require ( 'axios' ) ;
const cheerio = require ( 'cheerio' )
2022-09-27 16:45:50 -04:00
const url = interaction . options . data [ 0 ] . value ;
axios ( url )
. then ( response => {
const html = response . data ;
const $ = cheerio . load ( html ) ;
lyrics = $ ( '.para_row' ) . text ( ) ;
breakbar = "---------------------------------------------" ;
message . channel . send ( breakbar + "\n" + lyrics + "\n" + breakbar ) ;
//console.log(lyrics);
} )
. catch ( ( err ) => {
console . log ( err ) ;
interaction . reply ( "Please provide a valid url from https://www.karaoke-lyrics.net/" ) ;
} ) ;
} ,
options : [ { name : 'url' , description : 'the url of the song or "help"' , type : Constants . ApplicationCommandOptionTypes . STRING , required : true } ]
2022-03-10 20:30:03 -05:00
}
//TEST: https://www.karaoketexty.cz/texty-pisni/zoegirl/plain-170199