From 5a77443df6c75b5e2f378d578005733b91cdb679 Mon Sep 17 00:00:00 2001 From: MatteZ02 <47610069+MatteZ02@users.noreply.github.com> Date: Sat, 4 Jul 2020 22:17:20 +0300 Subject: [PATCH] Chore update 3.8 --- package.json | 2 +- src/commands/invite.js | 1 - src/commands/play.js | 57 +++++++++++-------------- src/commands/resume.js | 2 +- src/commands/stop.js | 2 +- src/events/clientEvents/handler.js | 61 ++++++++++++++------------- src/events/dispatcherEvents/finish.js | 1 + src/struct/client.js | 2 - src/struct/config/config.js | 8 ++-- src/struct/config/messages.js | 2 +- src/struct/funcs/exe.js | 2 +- 11 files changed, 66 insertions(+), 74 deletions(-) diff --git a/package.json b/package.json index 9aaaa6d5..7f4c32ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "musix", - "version": "3.7.2", + "version": "3.8.0", "description": "V3 for Musix the discord music bot", "main": "./index.js", "scripts": { diff --git a/src/commands/invite.js b/src/commands/invite.js index de3d97c1..2d25e485 100644 --- a/src/commands/invite.js +++ b/src/commands/invite.js @@ -12,6 +12,5 @@ module.exports = { .setURL(client.config.invite) .setColor(client.config.embedColor) msg.channel.send(embed); - msg.channel.send(client.messages.joinSupport + client.config.supportServer); } }; \ No newline at end of file diff --git a/src/commands/play.js b/src/commands/play.js index 6e46bc8b..44d3845f 100644 --- a/src/commands/play.js +++ b/src/commands/play.js @@ -49,23 +49,24 @@ module.exports = { const playlistId = url.split("/playlist/")[1].split("?")[0]; spotify.getPlaylist(playlistId).then( async function (data) { - searchPlaylist(data, client, msg, voiceChannel); - }, - function (err) { - console.log(err); - msg.channel.send(client.messages.noResultsSpotify); - } + console.log(data.body) + searchPlaylist(data, client, msg, voiceChannel); + }, + function (err) { + console.log(err); + msg.channel.send(client.messages.noResultsSpotify); + } ); } else if (url.includes("album")) { const albumId = url.split("/album/")[1].split("?")[0]; spotify.getAlbumTracks(albumId).then( async function (data) { - searchAlbum(data, client, msg, voiceChannel); - }, - function (err) { - console.log(err); - msg.channel.send(client.messages.noResultsSpotify); - } + searchAlbum(data, client, msg, voiceChannel); + }, + function (err) { + console.log(err); + msg.channel.send(client.messages.noResultsSpotify); + } ); } else if (url.includes("track")) { return msg.channel.send(client.messages.disabledSpotifySongs); @@ -115,8 +116,7 @@ module.exports = { return lmsg.edit(message); } else { ytsr( - searchString, - { + searchString, { limit: 5, }, function (err, res) { @@ -154,24 +154,21 @@ async function searchPlaylist(data, client, msg, voiceChannel) { const track = await data.body.tracks.items[i].track; await client.funcs.sleep(250); ytsr( - `${track.artists[0].name} ${track.name} audio`, - { + `${track.artists[0].name} ${track.name} audio`, { limit: 5, }, async function (err, res) { if (err) return console.log(err); if (!res.items[0]) { ytsr( - `${track.artists[0].name} ${track.name} lyrics`, - { + `${track.artists[0].name} ${track.name} lyrics`, { limit: 5, }, async function (err, res) { if (err) return console.log(err); if (!res.items[0]) { ytsr( - `${track.artists[0].name} ${track.name}`, - { + `${track.artists[0].name} ${track.name}`, { limit: 5, }, async function (err, res) { @@ -244,24 +241,21 @@ async function searchAlbum(data, client, msg, voiceChannel) { const track = await data.body.items[i]; await client.funcs.sleep(250); ytsr( - `${track.artists[0].name} ${track.name} audio`, - { + `${track.artists[0].name} ${track.name} audio`, { limit: 5, }, async function (err, res) { if (err) return console.log(err); if (!res.items[0]) { ytsr( - `${track.artists[0].name} ${track.name} lyrics`, - { + `${track.artists[0].name} ${track.name} lyrics`, { limit: 5, }, async function (err, res) { if (err) return console.log(err); if (!res.items[0]) { ytsr( - `${track.artists[0].name} ${track.name}`, - { + `${track.artists[0].name} ${track.name}`, { limit: 5, }, async function (err, res) { @@ -337,24 +331,21 @@ async function searchSong(data, client, msg, voiceChannel) { const track = await data.body.tracks.items[i].track; await client.funcs.sleep(250); ytsr( - `${track.artists[0].name} ${track.name} audio`, - { + `${track.artists[0].name} ${track.name} audio`, { limit: 5, }, async function (err, res) { if (err) return console.log(err); if (!res.items[0]) { ytsr( - `${track.artists[0].name} ${track.name} lyrics`, - { + `${track.artists[0].name} ${track.name} lyrics`, { limit: 5, }, async function (err, res) { if (err) return console.log(err); if (!res.items[0]) { ytsr( - `${track.artists[0].name} ${track.name}`, - { + `${track.artists[0].name} ${track.name}`, { limit: 5, }, async function (err, res) { @@ -418,4 +409,4 @@ async function searchSong(data, client, msg, voiceChannel) { )}\n${client.messages.failedToLoad + failed}`; } lmsg.edit(message); -} +} \ No newline at end of file diff --git a/src/commands/resume.js b/src/commands/resume.js index 5426b19a..58f39836 100644 --- a/src/commands/resume.js +++ b/src/commands/resume.js @@ -11,7 +11,7 @@ module.exports = { if (client.funcs.check(client, msg, command)) { if (!queue.paused) return msg.channel.send(client.messages.notPaused); queue.paused = false; - queue.connection.dispatcher.resume(true); + queue.connection.dispatcher.resume(); return msg.channel.send(client.messages.resumed); } } diff --git a/src/commands/stop.js b/src/commands/stop.js index b8232a42..825e86d9 100644 --- a/src/commands/stop.js +++ b/src/commands/stop.js @@ -15,7 +15,7 @@ module.exports = { queue.exists = false; } if (msg.guild.voice.channel) msg.guild.voice.channel.leave(); - client.queue.delete(guild.id); + client.queue.delete(msg.guild.id); return msg.channel.send(client.messages.stop); } queue.songs = []; diff --git a/src/events/clientEvents/handler.js b/src/events/clientEvents/handler.js index edc94901..260265e7 100644 --- a/src/events/clientEvents/handler.js +++ b/src/events/clientEvents/handler.js @@ -1,34 +1,37 @@ module.exports = function (client) { const Discord = require('discord.js'); client.on('ready', () => { - require(`./ready.js`).execute(client, Discord); - }).on('message', (msg) => { - require(`./msg.js`).execute(client, msg, Discord); - }).on('guildCreate', (guild) => { - require(`./guildCreate.js`).execute(client, guild); - }).on('voiceStateUpdate', (oldState, newState) => { - require(`./voiceStateUpdate.js`).execute(client, oldState, newState); - }).on('error', (error) => { - console.log(error); - }).on('debug', (info) => { - if (client.config.devMode) console.log(info); - }).on('invalidated', () => { - console.log("Client session invalidated! Exiting the process!") - process.exit(1); - }).on('rateLimit', (rateLimitInfo) => { + require(`./ready.js`).execute(client, Discord); + }).on('message', (msg) => { + require(`./msg.js`).execute(client, msg, Discord); + }).on('guildCreate', (guild) => { + require(`./guildCreate.js`).execute(client, guild); + }) + .on('guildDelete', (guild) => { + require(`./guildDelete.js`).execute(client, guild); + }).on('voiceStateUpdate', (oldState, newState) => { + require(`./voiceStateUpdate.js`).execute(client, oldState, newState); + }).on('error', (error) => { + console.log(error); + }).on('debug', (info) => { + if (client.config.devMode) console.log(info); + }).on('invalidated', () => { + console.log("Client session invalidated! Exiting the process!") + process.exit(1); + }).on('rateLimit', (rateLimitInfo) => { - }).on('shardDisconnect', (event, id) => { - client.logs.push(`Shard ${id} disconnected event ${event}`); - }).on('shardError', (error, shardId) => { - client.logs.push(`Shard ${shardId} error ${error}`); - }).on('shardReady', (id, unavailableGuilds) => { - client.logs.push(`Shard ${id} ready. Unavailable guilds: ${unavailableGuilds || 0}`); - }).on('shardReconnecting', (id) => { - client.logs.push(`shard ${id} reconnecting.`); - }).on('shardResume', (id, replayedEvents) => { - client.logs.push(`shard ${id} resume events ${replayedEvents}`); - }).on("warn", (info) => { - client.logs.push(`Warn! info: ${info}`); - console.log(`Warn! info: ${info}`); - }); + }).on('shardDisconnect', (event, id) => { + client.logs.push(`Shard ${id} disconnected event ${event}`); + }).on('shardError', (error, shardId) => { + client.logs.push(`Shard ${shardId} error ${error}`); + }).on('shardReady', (id, unavailableGuilds) => { + client.logs.push(`Shard ${id} ready. Unavailable guilds: ${unavailableGuilds || 0}`); + }).on('shardReconnecting', (id) => { + client.logs.push(`shard ${id} reconnecting.`); + }).on('shardResume', (id, replayedEvents) => { + client.logs.push(`shard ${id} resume events ${replayedEvents}`); + }).on("warn", (info) => { + client.logs.push(`Warn! info: ${info}`); + console.log(`Warn! info: ${info}`); + }); } \ No newline at end of file diff --git a/src/events/dispatcherEvents/finish.js b/src/events/dispatcherEvents/finish.js index 9c8e71ab..fd7de7be 100644 --- a/src/events/dispatcherEvents/finish.js +++ b/src/events/dispatcherEvents/finish.js @@ -53,6 +53,7 @@ function findSimilar(client, queue, prevSongs, guild) { youtubeAPIKey: client.config.api_key, }, async function (err, songs) { + console.log(songs) if (err) { console.log(err.message); return queue.textChannel.send(client.messages.error); diff --git a/src/struct/client.js b/src/struct/client.js index ab8ef05f..d3c9372e 100644 --- a/src/struct/client.js +++ b/src/struct/client.js @@ -29,7 +29,6 @@ module.exports = class extends Client { credential: admin.credential.cert(serviceAccount), }); this.commands = new Collection(); - this.commandAliases = new Collection(); this.settingCmd = new Collection(); this.queue = new Map(); this.funcs = {}; @@ -56,7 +55,6 @@ module.exports = class extends Client { const command = require(`../commands/${file}`); command.uses = 0; this.commands.set(command.name, command); - this.commandAliases.set(command.alias, command); } const settingFiles = fs .readdirSync(path.join(path.dirname(__dirname), "commands/settings")) diff --git a/src/struct/config/config.js b/src/struct/config/config.js index 3ad72649..17a79217 100644 --- a/src/struct/config/config.js +++ b/src/struct/config/config.js @@ -22,8 +22,8 @@ module.exports = { secondary_test_channel: "570531724002328577", devId: "360363051792203779", embedColor: "#b50002", - invite: "https://discordapp.com/oauth2/authorize?client_id=607266889537945605&permissions=3427328&scope=bot", - supportServer: "https://discord.gg/rvHuJtB", + invite: "https://musix-web.herokuapp.com/releases", + supportServer: "https://musix-web.herokuapp.com/discord", devMode: false, api: false, saveDB: true, @@ -40,7 +40,7 @@ module.exports = { djrole: null, startPlaying: true, bass: 1, - autoPlay: false, + autoPlay: true, }; module.exports.streamConfig = { @@ -99,4 +99,4 @@ module.exports.emojis = { stop: "<:stop:674685626108477519> ", stopWatch: ":stopwatch: ", volumeHigh: "<:volumehigh:674685637626167307> ", -}; +}; \ No newline at end of file diff --git a/src/struct/config/messages.js b/src/struct/config/messages.js index 24abc83a..1f044b0c 100644 --- a/src/struct/config/messages.js +++ b/src/struct/config/messages.js @@ -69,7 +69,7 @@ module.exports = { idOrMentionChannel: emojis.redx + "Please provide a channel id or mention a channel!", invalidGuild: emojis.redx + "Invalid guild id!", invalidSpotifyUrl: emojis.redx + "That url cannot be played! If you believe this is a mistake please contact support!", - inviteTitle: "Invite Musix to your Discord server!", + inviteTitle: "Invite a release of Musix to your discord server!", joined: emojis.green_check_mark + "Joined", joinSupport: "Join the musix support server: ", keySet: emojis.green_check_mark + "Key set!", diff --git a/src/struct/funcs/exe.js b/src/struct/funcs/exe.js index c20931e4..56023177 100644 --- a/src/struct/funcs/exe.js +++ b/src/struct/funcs/exe.js @@ -3,7 +3,7 @@ module.exports = function (msg, args, client, Discord, command) { if (!permissions.has("EMBED_LINKS")) return msg.channel.send(client.messages.noPermsEmbed); if (!permissions.has("USE_EXTERNAL_EMOJIS")) - return msg.channel.send(client.noPermsUseExternalEmojis); + return msg.channel.send(client.messages.noPermsUseExternalEmojis); if ( command.category === "music" && client.global.db.guilds[msg.guild.id].blacklist.includes(msg.channel.id)