From 1760fbcda11c5b72865d7040a8ae198d503cc452 Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Sun, 19 Apr 2020 17:08:37 +1000 Subject: [PATCH] music is fixed, it just needs polish now ^^ --- index.js | 3 +-- utils/music.js | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 45d4e76..6d07248 100644 --- a/index.js +++ b/index.js @@ -96,9 +96,8 @@ const init = async () => { // Login to Discord function failedToLogin (err) { client.logger.error('Couldn\'t login: ' + err) - process.exit(0) - }; + } if (client.devmode !== true) { client.login(client.config.token).catch(failedToLogin) diff --git a/utils/music.js b/utils/music.js index 7505328..9257e46 100644 --- a/utils/music.js +++ b/utils/music.js @@ -57,7 +57,6 @@ module.exports = client => { try { const id = await ytdl.getURLVideoID(query) resp = await fetch('https://invidious.snopyta.org/api/v1/videos/' + id) - console.log(resp) } catch (err) { resp = await fetch('https://invidious.snopyta.org/api/v1/search?q=' + encodeURIComponent(query)) } @@ -124,11 +123,44 @@ module.exports = client => { embed.setTitle('Please reply with a number `1-' + i + '` to select which song you want to add to the queue.') embed.setColor(client.embedColour(message.guild)) embed.setDescription(output) - const selection = await client.awaitReply(message, embed) - console.log(selection) + + let selection = await client.awaitReply(message, embed) + selection = Number(selection) switch (selection) { - + case 1: + video = videos[0] + break + case 2: + if (videos[1]) { + video = videos[1] + } else { + return message.channel.send('Invalid choice.') + } + break + case 3: + if (videos[2]) { + video = videos[2] + } else { + return message.channel.send('Invalid choice.') + } + break + case 4: + if (videos[3]) { + video = videos[3] + } else { + return message.channel.send('Invalid choice.') + } + break + case 5: + if (videos[4]) { + video = videos[4] + } else { + return message.channel.send('Invalid choice.') + } + break + default: + return message.channel.send('Invalid choice.') } } @@ -138,8 +170,6 @@ module.exports = client => { video = videos } - console.log(video) - // Add video to queue guild.queue.push({ video: video, requestedBy: message.member.id }) }