diff --git a/package.json b/package.json index 417dcb2b..4e2e39d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "musix", - "version": "3.9.0", + "version": "3.10.0", "description": "V3 for Musix the discord music bot", "main": "./index.js", "scripts": { @@ -48,4 +48,4 @@ "ytsr": "^0.1.15", "zlib-sync": "^0.1.7" } -} +} \ No newline at end of file diff --git a/src/commands/bass.js b/src/commands/bass.js index ec5638d2..db03c60d 100644 --- a/src/commands/bass.js +++ b/src/commands/bass.js @@ -3,7 +3,6 @@ module.exports = { description: "Boost the bass in your music!", alias: ["none"], usage: "", - cooldown: 5, onlyDev: false, permission: "MANAGE_MESSAGES", category: "audio modifiers", @@ -15,8 +14,8 @@ module.exports = { ); const bass = parseFloat(args[1]); if (client.funcs.check(client, msg, command)) { - if (queue.nigthCore) - return msg.channel.send(client.messages.disableNigthCore); + if (queue.nightCore) + return msg.channel.send(client.messages.disableNightCore); if (isNaN(bass)) return msg.channel.send(client.messages.validNumber); if (bass > 10) return msg.channel.send(client.messages.maxBass); if (bass < 0) return msg.channel.send(client.messages.positiveBass); diff --git a/src/commands/nigthcore.js b/src/commands/nightcore.js similarity index 68% rename from src/commands/nigthcore.js rename to src/commands/nightcore.js index 8381a537..0f274a97 100644 --- a/src/commands/nigthcore.js +++ b/src/commands/nightcore.js @@ -1,8 +1,8 @@ module.exports = { - name: "nigthcore", + name: "nightcore", alias: ["nc"], usage: "", - description: "Change nigthcore audio modifier on/off", + description: "Change nightcore audio modifier on/off", onlyDev: false, permission: "MANAGE_MESSAGES", category: "audio modifiers", @@ -10,16 +10,16 @@ module.exports = { const queue = client.queue.get(msg.guild.id); if (!args[1] && queue) return msg.channel.send( - `${client.messages.currentNigthCore}**${queue.nigthCore}**` + `${client.messages.currentNightCore}**${queue.nightCore}**` ); if (client.funcs.check(client, msg, command)) { if (args[1] === "true") { - queue.nigthCore = true; + queue.nightCore = true; } else if (args[1] === "false") { - queue.nigthCore = false; + queue.nightCore = false; } else return msg.channel.send(client.messages.boolean); let message; - message = client.messages.nigthCoreApplied.replace("%BOOLEAN%", args[1]); + message = client.messages.nightCoreApplied.replace("%BOOLEAN%", args[1]); return msg.channel.send(message); } }, diff --git a/src/commands/nowplaying.js b/src/commands/nowplaying.js index 6b105562..951ac7ed 100644 --- a/src/commands/nowplaying.js +++ b/src/commands/nowplaying.js @@ -38,7 +38,7 @@ module.exports = { .setURL(queue.songs[0].url) .setThumbnail(thumbnail.url) .setColor(client.config.embedColor); - if (queue.nigthCore) + if (queue.nightCore) embed.setDescription( `${client.messages.nowPlayingDesc} ${queue.songs[0].title} \nchannel: \`${queue.songs[0].info.author.name}\`` ); diff --git a/src/commands/search.js b/src/commands/search.js index 10239806..8be0057a 100644 --- a/src/commands/search.js +++ b/src/commands/search.js @@ -50,18 +50,12 @@ module.exports = { client.spotify.searchTracks(`track:${videos[videoIndex].title}`) .then(function (data) { client.funcs.handleVideo( - videoResults[0].link, - msg, - voiceChannel, - client, - false, - "ytdl", + videos[videoIndex].link, msg, voiceChannel, client, false, "ytdl", data.body.tracks.items[0] ); }, function (err) { console.log('Something went wrong!', err); }); - return client.funcs.handleVideo(videos[videoIndex].link, msg, voiceChannel, client, false, "ytdl"); }) } }; \ No newline at end of file diff --git a/src/commands/seek.js b/src/commands/seek.js index 323d8605..e091e64b 100644 --- a/src/commands/seek.js +++ b/src/commands/seek.js @@ -9,8 +9,8 @@ module.exports = { async execute(msg, args, client, Discord, command) { const queue = client.queue.get(msg.guild.id); if (client.funcs.check(client, msg, command)) { - if (queue.nigthCore) - return msg.channel.send(client.messages.disableNigthCore); + if (queue.nightCore) + return msg.channel.send(client.messages.disableNightCore); if (!args[1]) return msg.channel.send( `${client.messages.correctUsage}\`${ diff --git a/src/events/clientEvents/msg.js b/src/events/clientEvents/msg.js index faed2212..81cf2ea3 100644 --- a/src/events/clientEvents/msg.js +++ b/src/events/clientEvents/msg.js @@ -1,5 +1,3 @@ -const ms = require("ms"); - module.exports = { name: "message", async execute(client, msg, Discord) { diff --git a/src/events/dispatcherEvents/finish.js b/src/events/dispatcherEvents/finish.js index f189b363..ce832395 100644 --- a/src/events/dispatcherEvents/finish.js +++ b/src/events/dispatcherEvents/finish.js @@ -41,7 +41,7 @@ function findSimilar(client, queue, prevSongs, guild) { let retries = 0; const query = prevSongs[Math.floor(Math.random() * Math.floor(prevSongs.length))]; - if (!query || !query.track) return client.funcs.play(guild, queue.songs[0], client, 0, true); + if (!query || !query.track) return findSimilar(client, queue, prevSongs, guild); similarSongs.find({ title: query.track.name, artist: query.track.artists[0].name, @@ -52,7 +52,20 @@ function findSimilar(client, queue, prevSongs, guild) { }, async function (err, songs) { if (err) { + if ( + err.message == + 'The request cannot be completed because you have exceeded your quota.' + ) { + queue.voiceChannel.leave(); + queue.exists = false; + client.queue.delete(guild.id); + queue.textChannel.send(client.messages.quotaReached); + return; + } console.log(err.message); + queue.voiceChannel.leave(); + queue.exists = false; + client.queue.delete(guild.id); return queue.textChannel.send(client.messages.error); } if (songs[0]) { diff --git a/src/struct/client.js b/src/struct/client.js index c746bb56..cfb42f06 100644 --- a/src/struct/client.js +++ b/src/struct/client.js @@ -11,8 +11,8 @@ const SpotifyApi = require("spotify-web-api-node"); const YouTube = require("simple-youtube-api"); const config = require("./config/config"); -const myIntents = new Intents(); -myIntents.add( +const GatewayIntents = new Intents(); +GatewayIntents.add( 1 << 0, // GUILDS 1 << 7, // GUILD_VOICE_STATES 1 << 9, // GUILD_MESSAGES @@ -24,7 +24,7 @@ module.exports = class extends Client { disableEveryone: true, disabledEvents: ["TYPING_START"], ws: { - intents: myIntents + intents: GatewayIntents } }); diff --git a/src/struct/config/config.js b/src/struct/config/config.js index 3545b93f..20e71c6b 100644 --- a/src/struct/config/config.js +++ b/src/struct/config/config.js @@ -68,7 +68,7 @@ module.exports.queueConfig = { songs: [], volume: null, bass: null, - nigthCore: false, + nightCore: false, playing: false, paused: false, looping: false, diff --git a/src/struct/config/messages.js b/src/struct/config/messages.js index 1f044b0c..93a316a6 100644 --- a/src/struct/config/messages.js +++ b/src/struct/config/messages.js @@ -35,7 +35,7 @@ module.exports = { currentBass: emojis.loudSound + "The current bass is: ", currentDefaultBass: emojis.speaker + "Currect default bass level: ", currentDefaultVolume: emojis.speaker + "Current default volume is:", - currentNigthCore: emojis.speaker + "Currect Nigthcore setting: ", + currentNightCore: emojis.speaker + "Currect Nightcore setting: ", currentPrefix: "Current prefix:", currentVolume: emojis.loudSound + "The current volume is: ", dbSaved: emojis.green_check_mark + "DB Saved!", @@ -47,7 +47,7 @@ module.exports = { devMode: emojis.redx + "Dev mode has been turned on! Commands are only available to developer(s)!", disabledSpotifySongs: emojis.redx + "Spotify songs cannot be played currently!", - disableNigthCore: emojis.redx + "Please disable nigthCore in order to use this command!", + disableNightCore: emojis.redx + "Please disable nightCore in order to use this command!", dispatcherError: "Error with the dispatcher: ", djFalse: emojis.green_check_mark + "`DJ` now set to `false`", djRoleCreated: emojis.green_check_mark + @@ -84,8 +84,8 @@ module.exports = { mentionChannel: emojis.redx + "Please mention a channel!", musicCommandsDisabled: emojis.redx + "This channels has been blacklisted! Music commands cannot be used here!", - nigthCoreApplied: emojis.green_check_mark + - "NigthCore is now **%BOOLEAN%** this will be applied when the next song starts playing!", + nightCoreApplied: emojis.green_check_mark + + "NightCore is now **%BOOLEAN%** this will be applied when the next song starts playing!", noDj: emojis.redx + "You need the `DJ` role to use this command!", noLooping: emojis.repeat + "No longer looping the queue!", noLoopingSong: emojis.repeatSong + "No longer looping the song!", diff --git a/src/struct/funcs/end.js b/src/struct/funcs/end.js index 0f9f1f6e..d4c8ae08 100644 --- a/src/struct/funcs/end.js +++ b/src/struct/funcs/end.js @@ -2,11 +2,11 @@ module.exports = async function (client, msg, pos, command) { const seek = parseInt(pos); const queue = client.queue.get(msg.guild.id); if (command.name === "seek") { - queue.time = pos * 1000; + queue.time = seek * 1000; } else { queue.time = queue.connection.dispatcher.streamTime + queue.time; } queue.connection.dispatcher.end(); queue.endReason = "seek"; client.funcs.play(msg.guild, queue.songs[0], client, seek, false); -}; +}; \ No newline at end of file diff --git a/src/struct/funcs/handleVideo.js b/src/struct/funcs/handleVideo.js index 8c3aff99..be6feb66 100644 --- a/src/struct/funcs/handleVideo.js +++ b/src/struct/funcs/handleVideo.js @@ -39,7 +39,7 @@ module.exports = async function ( prevSongs: [], volume: client.global.db.guilds[msg.guild.id].defaultVolume, bass: client.global.db.guilds[msg.guild.id].bass, - nigthCore: false, + nightCore: false, playing: false, paused: false, looping: false, diff --git a/src/struct/funcs/play.js b/src/struct/funcs/play.js index 199bd0cf..27fb910e 100644 --- a/src/struct/funcs/play.js +++ b/src/struct/funcs/play.js @@ -1,13 +1,14 @@ +const { + Readable: ReadableStream +} = require("stream"); +const Discord = require("discord.js"); +const ytdl = require("ytdl-core"); +const { + streamConfig +} = require("../config/config.js"); +const prism = require("prism-media"); + module.exports = async function (guild, song, client, seek, play) { - const { - Readable: ReadableStream - } = require("stream"); - const Discord = require("discord.js"); - const ytdl = require("ytdl-core"); - const { - streamConfig - } = require("../config/config.js"); - const prism = require("prism-media"); const queue = client.queue.get(guild.id); if (!song) { queue.voiceChannel.leave(); @@ -47,7 +48,7 @@ module.exports = async function (guild, song, client, seek, play) { `bass=g=${queue.bass}`, ]; client.funcs.sleep(500); - if (queue.nigthCore) { + if (queue.nightCore) { ffmpegArgs.push("-af"); ffmpegArgs.push("asetrate=52920"); }