Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- var argh = msg.content.substring(8)
- var args = argh.split(",")
- var artist = args[1]
- var song = args[0]
- lyr.fetch(artist, song, function (err, lyrics) {
- if (err) return console.log(err)
- var lyra = lyrics.split('\n\n')
- // msg.channel.send(lyra.length)
- var ran = Math.floor((Math.random() * lyra.length))
- for (i = 0; i < lyra.length; i++) {
- if (lyra[i] === "") {
- lyra.splice(i)
- }
- if (lyra[i]) {
- if (lyra[i].replace(/[^\n]/g, "").length > 7) {
- lyra.splice(i)
- }
- }
- }
- // msg.channel.send(ran)
- if (lyra[ran] === 'Sorry, We don\'t have lyrics for this song yet.') {
- msg.channel.send('```Proper command usage is !lyrics song, artist```')
- return
- }
- var text = lyra[ran]
- // if (!text) {
- // text = lyra[0]
- // }
- var Image = Canvas.Image
- Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'f.ttf'), { family: 'futura' }); // eslint-disable-line max-len
- var img = new Image();
- var canvas = new Canvas(800, 500)
- var ctx = canvas.getContext('2d');
- var img = new Image();
- img.onload = function() {
- ctx.drawImage(img,0,0,800,500);
- ctx.fillStyle = 'center'
- ctx.fillStyle = 'white'
- // ctx.fillText(text,0,200)
- if (!text) {
- var array2 = lyrics.split('\n\n')
- var random = Math.floor((Math.random() * array2.length))
- // for (i = 0; i < array2.length; i++) {
- // if (array2[i] === "") {
- // array2.splice(i)
- // }
- // }
- text = array2[random]
- }
- // text = text.replace(/[\n\n]/g, "")
- // var arga = text.split('\n')
- // for (i = 0; i < arga.length; i++) {
- // if (arga[i].length < 3) {
- // arga.splice(i)
- // }
- // }
- // msg.channel.send(text)
- // var text5 = arga.join('\n')
- if (!text) {
- var array2 = lyrics.split('\n\n')
- text = array2[0]
- }
- var why = text.split('\n')
- console.log(why)
- console.log(why.length)
- var mes2 = text.replace(/[^\n]/g, "").length
- // msg.channel.send(mes2 + " mes2")
- var lim = why.length
- if (why.length > 4) {
- lim = 4
- mes2 = 4
- }
- var fontsize = 30
- var mes = 0
- var hello = 0
- var split = []
- console.log(why)
- lea = 1000
- if (why.length < 1000) {
- lea = why.length
- }
- for (i = 0; i < lea; i++) {
- console.log(i)
- var xd = why[i]
- // var jj = i
- ctx.font = fontsize + "px futura"
- var mes = ctx.measureText(why[i]).width
- if (mes > 400) {
- var length = why[i].length
- var array = xd.split("")
- for (j = length / 2;j < length;j++) {
- if (array[j] === " ") {
- split.push(j)
- // msg.channel.send("i pushed: " + j)
- }
- }
- var num = parseInt(split[0])
- var part1 = xd.substring(0, num)
- var part2 = xd.substring(num, xd.length)
- why.splice(i,1,part1,part2)
- lim++
- mes2++
- hello++
- }
- }
- console.log(why)
- for (i = 0; i < lim; i++) {
- if (why[i] == 'I\'m the sons of all I\'ve done') {
- why[i] = 'I\'m the son of all I\'ve done'
- }
- mes = ctx.measureText(why[i]).width
- // msg.channel.send(i)
- ctx.font = fontsize + "px futura"
- // msg.channel.send('mes ' + mes)
- var amount1 = ((800 - mes) / 2)
- // msg.channel.send(amount1)
- var msre = (50 * (mes2)) - 20
- var amount2 = ((500 - msre) / 2)
- ctx.fillText(why[i],amount1,amount2 + 50 * i)
- }
- msg.channel.send(hello)
- msg.channel.sendFile(canvas.toBuffer())
- }
- var numb = Math.floor(Math.random() * 4)
- img.src = 'Z:/No Bot Intended/lyricpics/' + numb + '.jpg'
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement