diff --git a/src/commands/play.js b/src/commands/play.js index 6fe79198..df7af62d 100644 --- a/src/commands/play.js +++ b/src/commands/play.js @@ -42,88 +42,86 @@ module.exports = { if (!voiceChannel.speakable) return msg.channel.send(client.messages.noPermsSpeak); if (url.match(/^https?:\/\/(open.spotify.com|spotify.com)(.*)$/)) { - if (!client.global.db.guilds[msg.guild.id].premium) - return msg.channel.send(client.messages.notPremium); const playlistId = url.split("/playlist/")[1].split("?")[0]; spotify.getPlaylist(playlistId).then( async function (data) { - const lmsg = await msg.channel.send(client.messages.loadingSongs); - let failed = 0; - for (let i = 0; data.body.tracks.items.length > i; i++) { - const track = await data.body.tracks.items[i].track; - await client.funcs.sleep(250); - await search( - `${track.artists[0].name} ${track.name} audio`, - async function (err, res) { - if (err) return console.log(err); - if (res.videos.length === 0) { - await search( - `${track.artists[0].name} ${track.name} lyrics`, - async function (err, res) { - if (err) return console.log(err); - if (res.videos.length === 0) { - await search( - `${track.artists[0].name} ${track.name}`, - async function (err, res) { - if (err) return console.log(err); - if (res.videos.length === 0) { - failed++; - return; - } - await client.funcs.handleVideo( - res.videos[0], - msg, - voiceChannel, - client, - true, - "ytdl" - ); + const lmsg = await msg.channel.send(client.messages.loadingSongs); + let failed = 0; + for (let i = 0; data.body.tracks.items.length > i; i++) { + const track = await data.body.tracks.items[i].track; + await client.funcs.sleep(250); + await search( + `${track.artists[0].name} ${track.name} audio`, + async function (err, res) { + if (err) return console.log(err); + if (res.videos.length === 0) { + await search( + `${track.artists[0].name} ${track.name} lyrics`, + async function (err, res) { + if (err) return console.log(err); + if (res.videos.length === 0) { + await search( + `${track.artists[0].name} ${track.name}`, + async function (err, res) { + if (err) return console.log(err); + if (res.videos.length === 0) { + failed++; + return; } - ); - return; - } - await client.funcs.handleVideo( - res.videos[0], - msg, - voiceChannel, - client, - true, - "ytdl" + await client.funcs.handleVideo( + res.videos[0], + msg, + voiceChannel, + client, + true, + "ytdl" + ); + } ); + return; } - ); - failed++; - return; - } - await client.funcs.handleVideo( - res.videos[0], - msg, - voiceChannel, - client, - true, - "ytdl" + await client.funcs.handleVideo( + res.videos[0], + msg, + voiceChannel, + client, + true, + "ytdl" + ); + } ); + failed++; + return; } - ); - } - let message; - if (failed === 0) { - message = client.messages.playlistAdded.replace( - "%TITLE%", - data.body.name - ); - } else { - message = `${client.messages.playlistAdded.replace( + await client.funcs.handleVideo( + res.videos[0], + msg, + voiceChannel, + client, + true, + "ytdl" + ); + } + ); + } + let message; + if (failed === 0) { + message = client.messages.playlistAdded.replace( + "%TITLE%", + data.body.name + ); + } else { + message = `${client.messages.playlistAdded.replace( "%TITLE%", data.body.name )}\n${client.messages.failedToLoad + failed}`; - } - lmsg.edit(message); - }, - function (err) { - console.log(err); - msg.channel.send(client.messages.noResultsSpotify); } + lmsg.edit(message); + }, + function (err) { + console.log(err); + msg.channel.send(client.messages.noResultsSpotify); + } ); } else if ( url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/) @@ -164,4 +162,4 @@ module.exports = { }); } }, -}; \ No newline at end of file +}; diff --git a/src/commands/settings.js b/src/commands/settings.js index a32b2fd7..dfbd5242 100644 --- a/src/commands/settings.js +++ b/src/commands/settings.js @@ -48,11 +48,6 @@ module.exports = { client.messages.settingsBassDesc, true ) - .addField( - client.messages.settingsSetKey, - client.messages.settingsSetKeyDesc, - true - ) .setFooter(footer) .setAuthor(client.user.username, client.user.displayAvatarURL) .setColor(client.config.embedColor); @@ -87,4 +82,4 @@ module.exports = { return msg.channel.send(embed); } }, -}; +}; \ No newline at end of file diff --git a/src/commands/settings/setKey.js b/src/commands/settings/setKey.js deleted file mode 100644 index db904b73..00000000 --- a/src/commands/settings/setKey.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - name: "setkey", - async execute(msg, args, client) { - msg.channel.send(client.messages.setKeyUsage); - }, -}; diff --git a/src/events/clientEvents/msg.js b/src/events/clientEvents/msg.js index b4d54773..ee0c7560 100644 --- a/src/events/clientEvents/msg.js +++ b/src/events/clientEvents/msg.js @@ -1,17 +1,7 @@ module.exports = { name: "message", async execute(client, msg, Discord) { - if (msg.author.bot) return; - if (!msg.guild && msg.content.startsWith("setkey")) { - const args = msg.content.split(" "); - if (!args[1] || !args[2]) - return msg.channel.send(client.messages.setKeyUsage); - client.config.db.collection("guilds").doc(args[2]).set({ - key: args[1], - }); - return msg.channel.send(client.messages.keySet); - } - if (!msg.guild) return; + if (msg.author.bot || !msg.guild) return; if (!client.global.db.guilds[msg.guild.id]) return; let prefix = client.global.db.guilds[msg.guild.id].prefix; const args = msg.content.slice(prefix.length).split(" "); diff --git a/src/struct/config/messages.js b/src/struct/config/messages.js index 93394c91..45d869c7 100644 --- a/src/struct/config/messages.js +++ b/src/struct/config/messages.js @@ -96,7 +96,7 @@ module.exports = { noResults: emojis.redx + "I could not obtain any search results!", noResultsLyrics: emojis.redx + "I could not obtain any results!", noResultsSpotify: emojis.redx + - "I could not obtain any results! Make sure you have a key set! More info with the setkey setting.", + "I could not obtain any results!", noServerQueue: emojis.redx + "There is nothing playing!", noSongs: emojis.redx + "That song does not exist!", notPremium: emojis.redx + "This is not a premium guild!", @@ -141,7 +141,6 @@ module.exports = { seekingPointPositive: emojis.redx + "The seeking point needs to be a positive number!", seekMax: emojis.redx + "The lenght of this song is %LENGTH% seconds! You can't seek further than that!", - setKeyUsage: "Usage: `setkey `. Get your key from by pressing `Get your web playback sdk access token`.\nThe key will expire in 60 minutes!\nDO THIS COMMAND IN THE DMS! YOUR KEY IS PRIVATE DO NOT SHARE IT WITH ANYONE!", settingsAnnounceSongs: "announcesongs", settingsAnnounceSongsDesc: "Whether to announce songs that start playing or not.", settingsBass: "bass", @@ -155,8 +154,6 @@ module.exports = { settingsPrefixDesc: "Change the guild specific prefix. (string)", settingsSetDj: "setdj", settingsSetDjDesc: "Set a DJ role. This will allow chosen users to freely use all Musix commands. This will automatically set the `permissions` settings to true in order for the `DJ` role to have effect!", - settingsSetKey: "setkey", - settingsSetKeyDesc: "Get instructions on how to set a spotify key.", settingsTitle: "Guild settings for Musix", settingsVolume: "volume", settingsVolumeDesc: "Change the default volume that the bot will start playing at. (number)",