From 94691bf1dc4df5c9c3ae9f633c251ec4e9b842b9 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Wed, 24 Jun 2020 11:00:06 +0200 Subject: [PATCH 01/40] :pencil: Add filters data --- config/filters.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 config/filters.json diff --git a/config/filters.json b/config/filters.json new file mode 100644 index 0000000..72969e9 --- /dev/null +++ b/config/filters.json @@ -0,0 +1,15 @@ +{ + "bassboost": "Bassboost", + "8D": "8D", + "vaporwave": "Vaporwave", + "nightcore": "Nightcore", + "phaser": "Phaser", + "tremolo": "Tremolo", + "vibrato": "Vibrato", + "reverse": "Reverse", + "treble": "Reverse", + "normalizer": "Normalizer", + "surrounding": "Surrounding", + "pulsator": "Pulsator", + "superequalizer": "Superequalizer" +} \ No newline at end of file From fcfea1deed93af44d2fefde8dc705f9474dffbcc Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Wed, 24 Jun 2020 11:00:15 +0200 Subject: [PATCH 02/40] :arrow_up: Bump discordjs/opus --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f94f81e..796dedc 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "author": "ZerioDev", "license": "MIT", "dependencies": { - "@discordjs/opus": "^0.1.0", + "@discordjs/opus": "^0.3.2", "discord-player": "^1.4.0", "discord.js": "^12.2.0" } From 7a1f8a854f8ae5b4b956ffa6366f60d2d85d5d0e Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Wed, 24 Jun 2020 11:00:27 +0200 Subject: [PATCH 03/40] :pencil: Use x emoji instead of tools --- config/emojis.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/emojis.json b/config/emojis.json index 0077c7d..70efdbd 100644 --- a/config/emojis.json +++ b/config/emojis.json @@ -1,6 +1,6 @@ { "music": ":musical_note:", "queue": ":bar_chart:", - "error": ":tools:", + "error": ":x:", "success": ":white_check_mark:" } From 838c1d0bdd0ef487f4b81828a7d01bff5f0ec19c Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Wed, 24 Jun 2020 11:00:38 +0200 Subject: [PATCH 04/40] :sparkles: Add filters management commands --- commands/filter.js | 41 +++++++++++++++++++++++++++++++++++++++++ commands/w-filters.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 commands/filter.js create mode 100644 commands/w-filters.js diff --git a/commands/filter.js b/commands/filter.js new file mode 100644 index 0000000..d37e53a --- /dev/null +++ b/commands/filter.js @@ -0,0 +1,41 @@ +const emotes = require ("../config/emojis.json"); +const filters = require("../config/filters.json"); +const Discord = require("discord.js") + +module.exports.run = async (client, message, args) => { + + if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); + + const filter = args[0]; + if(!filter) return message.channel.send(`**Please specify a valid filter to enable or disable ${emotes.error}**`); + + const filterToUpdate = Object.values(filters).find((f) => f.toLowerCase() === filter.toLowerCase()); + if(!filterToUpdate) return message.channel.send(`**This filter doesn't exist ${emotes.error}**`); + + const filterRealName = Object.keys(filters).find((f) => filters[f] === filterToUpdate); + + const queueFilters = client.player.getQueue(message.guild.id).filters + const filtersUpdated = {}; + filtersUpdated[filterRealName] = queueFilters[filterRealName] ? false : true; + client.player.setFilters(message.guild.id, filtersUpdated); + + if(filtersUpdated[filterRealName]){ + const pleaseWait = new Discord.MessageEmbed() + .setDescription("I'm adding the filter to the music, please wait... Note : the longer the music is, the longer the wait will be :musical_note:") + .setColor("BLUE"); + message.channel.send(pleaseWait); + } else { + const pleaseWait = new Discord.MessageEmbed() + .setDescription(`I'm disabling the filter on the music, please wait... Note : the longer the music is playing, the longer the wait will be... :musical_note:`) + .setColor("BLUE"); + message.channel.send(pleaseWait); + } + +} + +module.exports.config = { + name: "filter", + aliases: [] +}; \ No newline at end of file diff --git a/commands/w-filters.js b/commands/w-filters.js new file mode 100644 index 0000000..75e585d --- /dev/null +++ b/commands/w-filters.js @@ -0,0 +1,35 @@ +const emotes = require("../config/emojis.json"); +const filters = require("../config/filters.json"); +const Discord = require("discord.js"); + +module.exports.run = async (client, message) => { + + if (!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + + if (!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); + + const enabledEmoji = emotes.success; + const disabledEmoji = emotes.error; + + const filtersStatuses = [ [], [] ]; + + Object.keys(filters).forEach((filterName) => { + const array = filtersStatuses[0].length > filtersStatuses[1].length ? filtersStatuses[1] : filtersStatuses[0]; + array.push(filters[filterName] + " : " + (client.player.getQueue(message.guild.id).filters[filterName] ? enabledEmoji : disabledEmoji)); + }); + + const list = new Discord.MessageEmbed() + .setDescription("Liste de tous les filtres activés ou non.\nPour ajouter un filtre sur une musique `^filter`.") + .addField("**Filtres**", filtersStatuses[0].join('\n'), true) + .addField("** **", filtersStatuses[1].join('\n'), true) + .addField("** **", `Attention, sur la commande \`^filter\`.\nLe nom du filtre doit être en minuscule.`) + .setColor("ORANGE"); + + message.channel.send(list); + +}; + +module.exports.config = { + name: "w-filters", + aliases: [] +}; \ No newline at end of file From 3ce8273984da4e427fc8dd4155081cbac1d0192b Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Wed, 24 Jun 2020 11:00:58 +0200 Subject: [PATCH 05/40] :zap: Use track everywhere in the code --- commands/now-playing.js | 4 ++-- commands/pause.js | 4 ++-- commands/play.js | 28 +++++++++++++++++++--------- commands/queue.js | 11 +++++++---- commands/resume.js | 6 +++--- commands/skip.js | 4 ++-- 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/commands/now-playing.js b/commands/now-playing.js index f7e3f81..de05abb 100644 --- a/commands/now-playing.js +++ b/commands/now-playing.js @@ -6,9 +6,9 @@ module.exports.run = async (client, message) => { if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); - const song = await client.player.nowPlaying(message.guild.id); + const track = await client.player.nowPlaying(message.guild.id); - message.channel.send(`**Currently playing ${song.name} ${emotes.music}**`); + message.channel.send(`**Currently playing ${track.name} ${emotes.music}**`); }; diff --git a/commands/pause.js b/commands/pause.js index c47c072..ecd093b 100644 --- a/commands/pause.js +++ b/commands/pause.js @@ -8,9 +8,9 @@ module.exports.run = async (client, message) => { if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); - const song = await client.player.pause(message.guild.id); + const track = await client.player.pause(message.guild.id); - message.channel.send(`**Song ${song.name} paused ${emotes.success}**`); + message.channel.send(`**Track ${track.name} paused ${emotes.success}**`); }; diff --git a/commands/play.js b/commands/play.js index 59431d2..f7bcc00 100644 --- a/commands/play.js +++ b/commands/play.js @@ -6,17 +6,27 @@ module.exports.run = async (client, message, args) => { if (!args[0]) return message.channel.send(`**Please enter a music ${emotes.error}**`); - const aSongIsAlreadyPlaying = client.player.isPlaying(message.guild.id); + const aTrackIsAlreadyPlaying = client.player.isPlaying(message.guild.id); - // If there's already a song playing - if(aSongIsAlreadyPlaying){ - // Add the song to the queue - const song = await client.player.addToQueue(message.guild.id, args.join(" ")); - message.channel.send(`**Song ${song.name} added to queue ${emotes.music}**`); + // If there's already a track playing + if(aTrackIsAlreadyPlaying){ + // Add the track to the queue + const track = await client.player.addToQueue(message.guild.id, args.join(" ")); + message.channel.send(`**Track ${track.name} added to queue ${emotes.music}**`); } else { - // Else, play the song - const song = await client.player.play(message.member.voice.channel, args.join(" ")); - message.channel.send(`**Currently playing ${song.name} ${emotes.music}**`); + // Else, play the track + const track = await client.player.play(message.member.voice.channel, args.join(" ")); + message.channel.send(`**Currently playing ${track.name} ${emotes.music}**`); + const queue = client.player.getQueue(message.guild.id) + .on('end', () => { + message.channel.send('There is no more music in the queue!'); + }) + .on('trackChanged', (oldTrack, newTrack) => { + message.channel.send(`Now playing ${newTrack.name}...`); + }) + .on('channelEmpty', () => { + message.channel.send('Stop playing, there is no more member in the voice channel...'); + }); } }; diff --git a/commands/queue.js b/commands/queue.js index 36d1309..55d565d 100644 --- a/commands/queue.js +++ b/commands/queue.js @@ -6,11 +6,14 @@ module.exports.run = async (client, message) => { const queue = client.player.getQueue(message.guild.id); - if(!queue) return message.channel.send(`**No songs currently playing ${emotes.error}**`); + if(!queue) return message.channel.send(`**No tracks currently playing ${emotes.error}**`); - message.channel.send(`**Server queue ${emotes.queue}** \n`+(queue.songs.map((song, i) => { - return `${i === 0 ? 'Current' : `#${i+1}`} - ${song.name} | ${song.author}` - }).join('\n'))); + message.channel.send(`**Server queue ${emotes.queue}** \nCurrent - ${queue.playing.name} | ${queue.playing.author}\n`+ + ( + queue.tracks.map((track, i) => { + return `#${i+1} - ${track.name} | ${track.author}` + }).join('\n') + )); }; diff --git a/commands/resume.js b/commands/resume.js index 0564d29..3b9a769 100644 --- a/commands/resume.js +++ b/commands/resume.js @@ -4,11 +4,11 @@ module.exports.run = async (client, message) => { if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); - const song = await client.player.resume(message.guild.id); + const track = await client.player.resume(message.guild.id); - if(!song) return message.channel.send(`**No songs currently playing ${emotes.error}**`); + if(!track) return message.channel.send(`**No tracks currently playing ${emotes.error}**`); - message.channel.send(`**Song ${song.name} resumed ${emotes.success}**`); + message.channel.send(`**Track ${track.name} resumed ${emotes.success}**`); }; diff --git a/commands/skip.js b/commands/skip.js index b1dd767..0c7b149 100644 --- a/commands/skip.js +++ b/commands/skip.js @@ -6,9 +6,9 @@ module.exports.run = async (client, message) => { if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); - const song = await client.player.skip(message.guild.id); + const track = await client.player.skip(message.guild.id); - message.channel.send(`**Song ${song.name} skipped ${emotes.success}**`); + message.channel.send(`**Track ${track.name} skipped ${emotes.success}**`); }; From 58f9bacb9a8ffcea43c4a53f9671d10d9b8ff400 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:49:46 +0200 Subject: [PATCH 06/40] =?UTF-8?q?=F0=9F=93=9D=20Modification=20bot.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/bot.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/bot.json b/config/bot.json index 0648d3c..0790469 100644 --- a/config/bot.json +++ b/config/bot.json @@ -1,6 +1,7 @@ { - "prefix": "PREFIX BOT", + "prefix": "PREFIX", + + "game": "GAME", - "token_bot": "TOKEN BOT", - "youtube_api": "TOKEN YOUTUBE API" + "token_bot": "TOKEN" } From 56a0a60478746c88261fba9f358c14326a32535d Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:50:44 +0200 Subject: [PATCH 07/40] =?UTF-8?q?=F0=9F=93=9D=20Add=20filters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/filters.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/filters.json b/config/filters.json index 72969e9..9b847af 100644 --- a/config/filters.json +++ b/config/filters.json @@ -7,9 +7,9 @@ "tremolo": "Tremolo", "vibrato": "Vibrato", "reverse": "Reverse", - "treble": "Reverse", + "treble": "Treble", "normalizer": "Normalizer", "surrounding": "Surrounding", "pulsator": "Pulsator", "superequalizer": "Superequalizer" -} \ No newline at end of file +} From 23b33d53cc4f5945b9ba6a8d3e28d19336d74f73 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:51:49 +0200 Subject: [PATCH 08/40] =?UTF-8?q?=F0=9F=8E=89=20New=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 85 ++++++++++++++++++++++++-------------------------------- 1 file changed, 36 insertions(+), 49 deletions(-) diff --git a/index.js b/index.js index 050fcf5..f4d2b09 100644 --- a/index.js +++ b/index.js @@ -1,59 +1,46 @@ +//Modules const Discord = require("discord.js"); +const Enmap = require('enmap') const fs = require("fs"); + +//New client const client = new Discord.Client(); -const settings = require ("./config/bot.json") // The bot connects using the configuration file +//The bot connects using the configuration file +const settings = require ("./config/bot.json") -const { Player } = require("discord-player"); // Create a new Player (Youtube API key is your Youtube Data v3 key) - -const player = new Player(client, settings.youtube_api); // To easily access the player +//Create a new Player +const { Player } = require("discord-player") +//To easily access the player +const player = new Player(client) client.player = player; -client.on("ready", () => { - - console.log("The bot is ready to play music"); // If the bot is ready it sends a message in the console - -}); - -client.login(settings.token_bot); //The bot connects thanks to the token - -client.on('message', async (message) => { - - const prefix = settings.prefix; - - const messageArray = message.content.split(" "); - const cmd = messageArray[0].toLowerCase(); - const args = messageArray.slice(1); - - if(!message.content.startsWith(prefix)) return; - const commandfile = client.commands.get(cmd.slice(prefix.length)) || client.commands.get(client.aliases.get(cmd.slice(prefix.length))) - if(commandfile) commandfile.run(client,message,args) - -}); - -client.commands = new Discord.Collection(); -client.aliases = new Discord.Collection(); - -fs.readdir("./commands/", (err, files) => { - - const jsfiles = files.filter(f => f.split(".").pop() === "js") - - if(jsfiles.length <= 0) { - return console.log("Couldn't find any commands!"); - } - - jsfiles.forEach((file) => { - - console.log(`Loading command ${file}`); - - const command = require(`./commands/${file}`); - - client.commands.set(command.config.name, command); - command.config.aliases.forEach(alias => { - client.aliases.set(alias, command.config.name); - }); - +//Events +fs.readdir("./events/", (err, files) => { + if (err) return console.error(err); + files.forEach(file => { + const event = require(`./events/${file}`); + let eventName = file.split(".")[0]; + console.log(`Loading event ${eventName}`); + client.on(eventName, event.bind(null, client)); }); - }); + +//New commands +client.commands = new Enmap(); + +//Commands +fs.readdir("./commands/", (err, files) => { + if (err) return console.error(err); + files.forEach(file => { + if (!file.endsWith(".js")) return; + let props = require(`./commands/${file}`); + let commandName = file.split(".")[0]; + console.log(`Loading command ${commandName}`); + client.commands.set(commandName, props); + }); +}); + +//Login +client.login(settings.token_bot); From bf18c0f62387cd4ba333c9d3ba54e26e32f468c0 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:53:57 +0200 Subject: [PATCH 09/40] =?UTF-8?q?=F0=9F=93=9D=20Add=20enmap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 475bb05..f956e80 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "license": "MIT", "dependencies": { "@discordjs/opus": "^0.3.2", - "discord-player": "^1.4.0", - "discord.js": "^12.2.0" + "discord-player": "github:Androz2091/discord-player#develop", + "discord.js": "^12.2.0", + "enmap": "^5.3.1" } } From d6feb33bdae417af04953b157f625a7b093000a9 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:55:03 +0200 Subject: [PATCH 10/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/clear-queue.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/commands/clear-queue.js b/commands/clear-queue.js index 6eb9e4b..7f100ce 100644 --- a/commands/clear-queue.js +++ b/commands/clear-queue.js @@ -1,18 +1,18 @@ const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") -module.exports.run = async (client, message) => { +exports.run = async (client, message, args) => { - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); - if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); + //If there's no music + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`No music playing on this server ${emotes.error}`); + //The bot removes the waiting list client.player.clearQueue(message.guild.id); - message.channel.send(`**Queue cleared ${emotes.success}**`); + //Success message + message.channel.send(`Queue cleared ${emotes.success}`); -}; - -module.exports.config = { - name: "clear-queue", - aliases: [] -}; +} From 72690ec26f01254fd5ab52c685b83b1e04c4ef47 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:55:59 +0200 Subject: [PATCH 11/40] =?UTF-8?q?=E2=9C=A8=20Add=20filters=20management=20?= =?UTF-8?q?commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/filter.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/commands/filter.js b/commands/filter.js index d37e53a..42e7143 100644 --- a/commands/filter.js +++ b/commands/filter.js @@ -2,18 +2,23 @@ const emotes = require ("../config/emojis.json"); const filters = require("../config/filters.json"); const Discord = require("discord.js") -module.exports.run = async (client, message, args) => { +exports.run = async (client, message, args) => { - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); - if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); + //If there's no music + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`No music playing on this server ${emotes.error}`); + //Filter const filter = args[0]; - if(!filter) return message.channel.send(`**Please specify a valid filter to enable or disable ${emotes.error}**`); - + if(!filter) return message.channel.send(`Please specify a valid filter to enable or disable ${emotes.error}`); + const filterToUpdate = Object.values(filters).find((f) => f.toLowerCase() === filter.toLowerCase()); - if(!filterToUpdate) return message.channel.send(`**This filter doesn't exist ${emotes.error}**`); - + + //If he can't find the filter + if(!filterToUpdate) return message.channel.send(`This filter doesn't exist ${emotes.error}`); + const filterRealName = Object.keys(filters).find((f) => filters[f] === filterToUpdate); const queueFilters = client.player.getQueue(message.guild.id).filters @@ -21,21 +26,16 @@ module.exports.run = async (client, message, args) => { filtersUpdated[filterRealName] = queueFilters[filterRealName] ? false : true; client.player.setFilters(message.guild.id, filtersUpdated); - if(filtersUpdated[filterRealName]){ - const pleaseWait = new Discord.MessageEmbed() - .setDescription("I'm adding the filter to the music, please wait... Note : the longer the music is, the longer the wait will be :musical_note:") - .setColor("BLUE"); - message.channel.send(pleaseWait); + if(filtersUpdated[filterRealName]) { + + //The bot adds the filter on the music + message.channel.send(`I'm adding the filter to the music, please wait... Note : the longer the music is, the longer the wait will be ${emotes.music}`); + } else { - const pleaseWait = new Discord.MessageEmbed() - .setDescription(`I'm disabling the filter on the music, please wait... Note : the longer the music is playing, the longer the wait will be... :musical_note:`) - .setColor("BLUE"); - message.channel.send(pleaseWait); + + //The bot removes the filter from the music + message.channel.send(`I'm disabling the filter on the music, please wait... Note : the longer the music is playing, the longer the wait will be ${emotes.music}`); + } } - -module.exports.config = { - name: "filter", - aliases: [] -}; \ No newline at end of file From 1bd779b25690b22cd017be8f9fe335d51722a3b2 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:56:45 +0200 Subject: [PATCH 12/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/now-playing.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/commands/now-playing.js b/commands/now-playing.js index de05abb..46faf2f 100644 --- a/commands/now-playing.js +++ b/commands/now-playing.js @@ -1,18 +1,17 @@ const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") -module.exports.run = async (client, message) => { +exports.run = async (client, message, args) => { - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); - if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); + //If there's no music + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`No music playing on this server ${emotes.error}`); - const track = await client.player.nowPlaying(message.guild.id); + const song = await client.player.nowPlaying(message.guild.id); - message.channel.send(`**Currently playing ${track.name} ${emotes.music}**`); + //Message + message.channel.send(`Currently playing ${song.name} ${emotes.music}\nProgression : [${client.player.createProgressBar(message.guild.id)}]`); -}; - -module.exports.config = { - name: "now-playing", - aliases: [] -}; +} From 86c9618d02a9ad3fc44523e2374250e5c770551b Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:57:12 +0200 Subject: [PATCH 13/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/pause.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/commands/pause.js b/commands/pause.js index ecd093b..eeac198 100644 --- a/commands/pause.js +++ b/commands/pause.js @@ -1,20 +1,17 @@ +const emotes = require ("../config/emojis.json"); const Discord = require("discord.js") -const fs = require("fs") -const emotes = require ("../config/emojis.json") -module.exports.run = async (client, message) => { +exports.run = async (client, message, args) => { - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); - if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); + //If there's no music + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`No music playing on this server ${emotes.error}`); const track = await client.player.pause(message.guild.id); - message.channel.send(`**Track ${track.name} paused ${emotes.success}**`); + //Message + message.channel.send(`Song ${track.name} paused ${emotes.success}`); -}; - -module.exports.config = { - name: "pause", - aliases: [] -} \ No newline at end of file +} From 2670a61c3def449639aad6bc8438a7f459046cab Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:57:40 +0200 Subject: [PATCH 14/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/play.js | 63 +++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/commands/play.js b/commands/play.js index f7bcc00..b70894d 100644 --- a/commands/play.js +++ b/commands/play.js @@ -1,37 +1,40 @@ const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") -module.exports.run = async (client, message, args) => { +exports.run = async (client, message, args) => { - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); + + //If no music is provided + if (!args[0]) return message.channel.send(`Please enter a music ${emotes.error}`); - if (!args[0]) return message.channel.send(`**Please enter a music ${emotes.error}**`); - const aTrackIsAlreadyPlaying = client.player.isPlaying(message.guild.id); - // If there's already a track playing - if(aTrackIsAlreadyPlaying){ - // Add the track to the queue - const track = await client.player.addToQueue(message.guild.id, args.join(" ")); - message.channel.send(`**Track ${track.name} added to queue ${emotes.music}**`); - } else { - // Else, play the track - const track = await client.player.play(message.member.voice.channel, args.join(" ")); - message.channel.send(`**Currently playing ${track.name} ${emotes.music}**`); - const queue = client.player.getQueue(message.guild.id) - .on('end', () => { - message.channel.send('There is no more music in the queue!'); - }) - .on('trackChanged', (oldTrack, newTrack) => { - message.channel.send(`Now playing ${newTrack.name}...`); - }) - .on('channelEmpty', () => { - message.channel.send('Stop playing, there is no more member in the voice channel...'); - }); - } -}; + // If there's already a track playing + if(aTrackIsAlreadyPlaying){ - -module.exports.config = { - name: "play", - aliases: [] -}; \ No newline at end of file + // Add the track to the queue + const track = await client.player.addToQueue(message.guild.id, args.join(" ")); + message.channel.send(`Track ${track.name} added to queue ${emotes.music}`); + + } else { + + // Else, play the song + const song = await client.player.play(message.member.voice.channel, args.join(" ")); + message.channel.send(`Currently playing ${song.name} ${emotes.music}`); + + const queue = client.player.getQueue(message.guild.id) + + //Events + .on('end', () => { + message.channel.send(`There is no more music in the queue ${emotes.error}`); + }) + .on('trackChanged', (oldTrack, newTrack) => { + message.channel.send(`Now playing ${newTrack.name} ... ${emotes.music}`); + }) + .on('channelEmpty', () => { + message.channel.send(`Stop playing, there is no more member in the voice channel ${emotes.error}`); + }); + } + } From c40ddec7839357d84c029723c4225a58c969ffc8 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:58:00 +0200 Subject: [PATCH 15/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/queue.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/commands/queue.js b/commands/queue.js index 55d565d..533a9fb 100644 --- a/commands/queue.js +++ b/commands/queue.js @@ -1,24 +1,23 @@ const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") -module.exports.run = async (client, message) => { +exports.run = async (client, message, args) => { - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); + //Get queue const queue = client.player.getQueue(message.guild.id); - if(!queue) return message.channel.send(`**No tracks currently playing ${emotes.error}**`); + //If there's no music + if(!queue) return message.channel.send(`No songs currently playing ${emotes.error}`); - message.channel.send(`**Server queue ${emotes.queue}** \nCurrent - ${queue.playing.name} | ${queue.playing.author}\n`+ + //Message + message.channel.send(`**Server queue ${emotes.queue}**\nCurrent - ${queue.playing.name} | ${queue.playing.author}\n`+ ( queue.tracks.map((track, i) => { return `#${i+1} - ${track.name} | ${track.author}` }).join('\n') )); -}; - - -module.exports.config = { - name: "queue", - aliases: [] -}; +} From 8cb5dc3c275284a02b916242043a63994540f436 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:58:36 +0200 Subject: [PATCH 16/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/resume.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/commands/resume.js b/commands/resume.js index 3b9a769..02c69bc 100644 --- a/commands/resume.js +++ b/commands/resume.js @@ -1,18 +1,18 @@ const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") -module.exports.run = async (client, message) => { +exports.run = async (client, message, args) => { - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); - const track = await client.player.resume(message.guild.id); + //Get song + const song = await client.player.resume(message.guild.id); - if(!track) return message.channel.send(`**No tracks currently playing ${emotes.error}**`); + //If there's no music + if(!song) return message.channel.send(`No songs currently playing ${emotes.error}`); - message.channel.send(`**Track ${track.name} resumed ${emotes.success}**`); + //Message + message.channel.send(`Song ${song.name} resumed ${emotes.success}`); -}; - -module.exports.config = { - name: "resume", - aliases: [] -}; \ No newline at end of file +} From 70fdd8c432bead4f2fa297fb7de0039284da1f68 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:59:27 +0200 Subject: [PATCH 17/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code=20/=20command=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/loop.js | 33 +++++++++++++++++++++++++++++++++ commands/set-repeat.js | 24 ------------------------ 2 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 commands/loop.js delete mode 100644 commands/set-repeat.js diff --git a/commands/loop.js b/commands/loop.js new file mode 100644 index 0000000..2336c44 --- /dev/null +++ b/commands/loop.js @@ -0,0 +1,33 @@ +const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") + +exports.run = async (client, message, args) => { + + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); + + //If there's no music + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`No music playing on this server ${emotes.error}`); + + //Repeat mode + const repeatMode = client.player.getQueue(message.guild.id).repeatMode; + + //If the mode is enabled + if(repeatMode) { + + client.player.setRepeatMode(message.guild.id, false); + + //Message + return message.channel.send(`Repeat mode disabled ${emotes.success}`); + + //If the mode is disabled + } else { + + client.player.setRepeatMode(message.guild.id, true); + + //Message + return message.channel.send(`Repeat mode enabled ${emotes.success}`); + + } + +} diff --git a/commands/set-repeat.js b/commands/set-repeat.js deleted file mode 100644 index bb095dc..0000000 --- a/commands/set-repeat.js +++ /dev/null @@ -1,24 +0,0 @@ -const emotes = require ("../config/emojis.json"); - -module.exports.run = async (client, message) => { - - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); - - if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); - - const repeatMode = client.player.getQueue(message.guild.id).repeatMode; - - if(repeatMode){ - client.player.setRepeatMode(message.guild.id, false); - return message.channel.send(`**Repeat mode disabled ${emotes.success}**`); - } else { - client.player.setRepeatMode(message.guild.id, true); - return message.channel.send(`**Repeat mode enabled ${emotes.success}**`); - } - -}; - -module.exports.config = { - name: "set-repeat", - aliases: [] -}; From 6514c0c6aa5200c870c832796bc30048dc74abaf Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:02:35 +0200 Subject: [PATCH 18/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code=20/=20command=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/set-volume.js | 21 --------------------- commands/volume.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 21 deletions(-) delete mode 100644 commands/set-volume.js create mode 100644 commands/volume.js diff --git a/commands/set-volume.js b/commands/set-volume.js deleted file mode 100644 index e257d55..0000000 --- a/commands/set-volume.js +++ /dev/null @@ -1,21 +0,0 @@ -const emotes = require ("../config/emojis.json"); - -module.exports.run = async (client, message, args) => { - - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); - - if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); - if(!args[0]) return message.channel.send(`**Please enter a number ${emotes.error}**`); - if(isNaN(args[0])) return message.channel.send(`**Please enter a valid number ${emotes.error}**`); - - client.player.setVolume(message.guild.id, parseInt(args.join(" "))); - - message.channel.send("**Volume set to** `" + args.join(" ") + "`" + `** ** ${emotes.success}`); - - -}; - -module.exports.config = { - name: "set-volume", - aliases: [] -}; diff --git a/commands/volume.js b/commands/volume.js new file mode 100644 index 0000000..d249e28 --- /dev/null +++ b/commands/volume.js @@ -0,0 +1,30 @@ +const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") + +exports.run = async (client, message, args) => { + + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); + + //If there's no music + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`No music playing on this server ${emotes.error}`); + + //Args + if(!args[0]) return message.channel.send(`Please enter a number ${emotes.error}`); + + //Security modification + if(isNaN(args[0])) return message.channel.send(`Please enter a valid number ${emotes.error}`); + if(100 < args[0]) return message.channel.send(`Please enter a valid number ${emotes.error}`) + if(args[0] <=0) return message.channel.send(`Please enter a valid number ${emotes.error}`) + + //Cannot put (-) or (+) + if(message.content.includes(".")) return message.channel.send(`Please enter a valid number ${emotes.error}`) + if(message.content.includes("+")) return message.channel.send(`Please enter a valid number ${emotes.error}`) + + //Set volume + client.player.setVolume(message.guild.id, parseInt(args.join(" "))); + + //Message + message.channel.send(`Volume set to \`${args.join(" ")}\` ${emotes.success}`); + +} From a1e700002f005daae42fddf967742ae2042ddccc Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:03:07 +0200 Subject: [PATCH 19/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/shuffle.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/commands/shuffle.js b/commands/shuffle.js index 0040a2b..7b18769 100644 --- a/commands/shuffle.js +++ b/commands/shuffle.js @@ -1,17 +1,17 @@ const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") -module.exports.run = async (client, message) => { +exports.run = async (client, message, args) => { - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); - if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); + //If there's no music + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`No music playing on this server ${emotes.error}`); client.player.shuffle(message.guild.id); - return message.channel.send(`**Queue shuffled ${emotes.success}**`); - -}; -module.exports.config = { - name: "shuffle", - aliases: [] -}; + //Message + return message.channel.send(`Queue shuffled ${emotes.success}`); + +} From d5d9bc30f8d5bcc2cb76fe029fcd4e656fe7b335 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:03:52 +0200 Subject: [PATCH 20/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/skip.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/commands/skip.js b/commands/skip.js index 0c7b149..52cdb84 100644 --- a/commands/skip.js +++ b/commands/skip.js @@ -1,18 +1,17 @@ const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") -module.exports.run = async (client, message) => { +exports.run = async (client, message, args) => { - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); - if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); + //If there's no music + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`No music playing on this server ${emotes.error}`); const track = await client.player.skip(message.guild.id); - message.channel.send(`**Track ${track.name} skipped ${emotes.success}**`); + //Message + message.channel.send(`Song ${track.name} skipped ${emotes.success}`); -}; - -module.exports.config = { - name: "skip", - aliases: [] -}; +} From e6785f0b50ca7f0d9bb8bf08710b519e03187e89 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:04:16 +0200 Subject: [PATCH 21/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/stop.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/commands/stop.js b/commands/stop.js index 8474e45..5a7dea0 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -1,18 +1,18 @@ const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") -module.exports.run = async (client, message) => { +exports.run = async (client, message, args) => { - if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); - if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); + //If there's no music + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`No music playing on this server ${emotes.error}`); + //Stop player client.player.stop(message.guild.id); - message.channel.send(`**Music stopped ${emotes.success}**`); + //Message + message.channel.send(`Music stopped ${emotes.success}`); -}; - -module.exports.config = { - name: "stop", - aliases: [] -}; +} From e89cae3bf6f040d9bb62f541d7ee453f2639ecee Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:04:57 +0200 Subject: [PATCH 22/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/w-filters.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/commands/w-filters.js b/commands/w-filters.js index 75e585d..d2b6cd1 100644 --- a/commands/w-filters.js +++ b/commands/w-filters.js @@ -1,13 +1,17 @@ -const emotes = require("../config/emojis.json"); -const filters = require("../config/filters.json"); -const Discord = require("discord.js"); +const config = require ("../config/bot.json"); +const emotes = require ("../config/emojis.json"); +const filters = require ("../config/filters.json"); +const Discord = require("discord.js") -module.exports.run = async (client, message) => { +exports.run = async (client, message, args) => { - if (!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`); + //If the member is not in a voice channel + if(!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${emotes.error}`); - if (!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`); + //If there's no music + if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`No music playing on this server ${emotes.error}`); + //Emojis const enabledEmoji = emotes.success; const disabledEmoji = emotes.error; @@ -18,18 +22,14 @@ module.exports.run = async (client, message) => { array.push(filters[filterName] + " : " + (client.player.getQueue(message.guild.id).filters[filterName] ? enabledEmoji : disabledEmoji)); }); + //List embed const list = new Discord.MessageEmbed() - .setDescription("Liste de tous les filtres activés ou non.\nPour ajouter un filtre sur une musique `^filter`.") - .addField("**Filtres**", filtersStatuses[0].join('\n'), true) + .setDescription(`List of all filters enabled or disabled.\nTo add a filter to a \`${config.prefix}filter\` music.`) + .addField("**Filters**", filtersStatuses[0].join('\n'), true) .addField("** **", filtersStatuses[1].join('\n'), true) - .addField("** **", `Attention, sur la commande \`^filter\`.\nLe nom du filtre doit être en minuscule.`) .setColor("ORANGE"); + //Message message.channel.send(list); -}; - -module.exports.config = { - name: "w-filters", - aliases: [] -}; \ No newline at end of file +} From c242ed43a611a3bf70db749b80e79244ee5030b6 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:05:53 +0200 Subject: [PATCH 23/40] =?UTF-8?q?=F0=9F=93=9D=20New=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/help.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 commands/help.js diff --git a/commands/help.js b/commands/help.js new file mode 100644 index 0000000..c3c773b --- /dev/null +++ b/commands/help.js @@ -0,0 +1,17 @@ +const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") + +exports.run = async (client, message, args) => { + + //New embed + const help = new Discord.MessageEmbed() + .setDescription("Find the list of commands available on this panel.") + .addField("**Music**", "`play`, `pause`, `resume`, `queue`, `clear-queue`, `shuffle`, `np`, `loop`, `volume`, `skip`, `stop`") + .addField("**Filters**", "`bassboost`, `tremolo`, `vibrato`, `treble`, `8D`, `normalizer`, `surrounding`, `nightcore`, `vaporwave`, `superequalizer`, `phaser`, `reverse`, `pulsator`") + .setFooter("To use filters, ^filter (the filter). Example : ^filter 8D.") + .setColor("ORANGE") + + //Message + message.channel.send(help) + +} From 09483a5eda95d8e4f6c1cb51b9cebece1bea986e Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:06:54 +0200 Subject: [PATCH 24/40] =?UTF-8?q?=E2=8C=9B=EF=B8=8F=20Add=20events?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- events/message.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 events/message.js diff --git a/events/message.js b/events/message.js new file mode 100644 index 0000000..0de7eca --- /dev/null +++ b/events/message.js @@ -0,0 +1,27 @@ +const config = require(`../config/bot.json`) + +module.exports = (client, message) => { + + //Ignore all bots + if (message.author.bot) return; + + //Prefix + let prefix = config.prefix + + //Ignore messages not starting with the prefix (in config.json) + if (message.content.indexOf(prefix) !== 0) return; + + //Our standard argument/command name definition. + const args = message.content.slice(prefix.length).trim().split(/ +/g); + const command = args.shift().toLowerCase(); + + //Grab the command data from the client.commands Enmap + const cmd = client.commands.get(command); + + //If that command doesn't exist, silently exit and do nothing + if (!cmd) return; + + //Run the command + cmd.run(client, message, args); + +}; From 289f1f6fefa08a47ac359ca23d0116044fddd22b Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:07:24 +0200 Subject: [PATCH 25/40] =?UTF-8?q?=E2=8C=9B=EF=B8=8F=20Add=20events?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- events/ready.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 events/ready.js diff --git a/events/ready.js b/events/ready.js new file mode 100644 index 0000000..692338a --- /dev/null +++ b/events/ready.js @@ -0,0 +1,11 @@ +const config = require(`../config/bot.json`) + +module.exports = async (client) => { + + //If the bot is ready it sends a message in the console + console.log(`Ready on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`); + + //Game + client.user.setActivity(config.game) + +} From 2f6f78003c5fa4193b1f5decf10d7e56c23b9da5 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:08:34 +0200 Subject: [PATCH 26/40] =?UTF-8?q?=F0=9F=93=9D=20Modifications=20handler=20?= =?UTF-8?q?/=20code=20/=20command=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/{now-playing.js => np.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename commands/{now-playing.js => np.js} (100%) diff --git a/commands/now-playing.js b/commands/np.js similarity index 100% rename from commands/now-playing.js rename to commands/np.js From c2487d3ef7e45a41c69f08a7f2896da6cd788c69 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:18:13 +0200 Subject: [PATCH 27/40] =?UTF-8?q?=F0=9F=8E=89=20Modification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 80 ++++++++++++++++++++----------------------------------- 1 file changed, 29 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index eb5214b..ed45bb4 100644 --- a/README.md +++ b/README.md @@ -10,18 +10,19 @@ For the bot to be able to start, please complete the file with your credentials ```js { - "prefix": "PREFIX BOT", + "prefix": "PREFIX", + + "game": "GAME", - "token_bot": "TOKEN BOT", - "youtube_api": "TOKEN YOUTUBE API" + "token_bot": "TOKEN" } ``` Reminder : - `prefix`, the prefix that will be set to use the bot. +- `game`, the status of the bot. - `token_bot`, the token of the bot available on the [Discord Developers](https://discordapp.com/developers/applications) section. -- `youtube_api`, your youtube token available on the [Google console](https://console.developers.google.com). To customize the emojis go to the file `emojis.json`. Emojis are already defined by default but you can modify them if you wish. @@ -30,7 +31,7 @@ Emojis are already defined by default but you can modify them if you wish. { "music": ":musical_note:", "queue": ":bar_chart:", - "error": ":tools:", + "error": ":x:", "success": ":white_check_mark:" } ``` @@ -44,55 +45,32 @@ npm i (name of each missing module) All you have to do is turn on your bot ! -- `play `, play music in a vocal salon. -- `pause`, pauses the current music. -- `resume`, puts the current music back on. -- `queue`, see the next musics. -- `clear-queue`, delete the next music. -- `now-playing`, see music in progress. -- `set-volume <...>`, change the volume. -- `set-repeat`to enable or disable the repeat function. -- `skip`, skip to next music. -- `stop`, stop all music. +### 🎵 Music commands +``` +play , play music in a vocal salon. +pause, pause the current music. +resume, puts the current music back on. +queue, see the next musics. +np`, see music in progress. +volume <1 - 100>, change the volume. +loop, to enable or disable the repeat function. +skip, skip to next music. +stop, stop all music. +filter, add / remove filters. +w-filters, see filters. +clear-queue, delete the next music. +``` + +### 💡 General commands + +``` +help, see the list of available orders. +ping, see the bot latency. +``` Utilities (to change the code) : -Functions available with the `discord-player` module that you can use : - -```js -// Play a song in the voice channel and init the guild queue -client.player.play(voiceChannel, songName); - -// Add a song to the queue -client.player.addToQueue(guildID, songName); -// Clear the queue -client.player.clearQueue(guildID); -// Get the queue -client.player.getQueue(guildID); -// Skip the current song -client.player.skip(guildID); - - -// Pause -client.player.pause(guildID); -// Resume -client.player.resume(guildID); -// Stop -client.player.stop(guildID); - -// Check if music is playing in a guild -client.player.isPlaying(guildID); -// Get the currently playing song -client.player.nowPlaying(guildID); - - -// Current song will be repeated indefinitely -client.player.setRepeatMode(true); -// Current song will no longer be repeated indefinitely -client.player.setRepeatMode(false); -``` - Find all the functions available on the official code [right here](https://github.com/Androz2091/discord-player). -This is used with [Discord.js](https://www.npmjs.com/package/discord.js) and [discord-player](https://www.npmjs.com/package/discord-player). +This is used with [discord.js](https://www.npmjs.com/package/discord.js) and [discord-player](https://www.npmjs.com/package/discord-player). From 18f66e3d5028a1cb5001e43cde14b3a4e6e8636c Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:18:40 +0200 Subject: [PATCH 28/40] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ed45bb4..962cb3a 100644 --- a/README.md +++ b/README.md @@ -52,12 +52,12 @@ play , play music in a vocal salon. pause, pause the current music. resume, puts the current music back on. queue, see the next musics. -np`, see music in progress. +np, see music in progress. volume <1 - 100>, change the volume. loop, to enable or disable the repeat function. skip, skip to next music. stop, stop all music. -filter, add / remove filters. +filter , add / remove filters. w-filters, see filters. clear-queue, delete the next music. ``` From e2ce6a98443aadcd17a9d5331ea94e1b726bd8dd Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:20:14 +0200 Subject: [PATCH 29/40] =?UTF-8?q?=F0=9F=93=9D=20New=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/ping.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 commands/ping.js diff --git a/commands/ping.js b/commands/ping.js new file mode 100644 index 0000000..64cc37f --- /dev/null +++ b/commands/ping.js @@ -0,0 +1,9 @@ +const emotes = require ("../config/emojis.json"); +const Discord = require("discord.js") + +exports.run = async (client, message, args) => { + + //Message + message.channel.send(`Ping : ${client.ws.ping} ${emotes.success}`) + +} From 43456b4098f78889f68dea3bf9a71b9c03737109 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:20:59 +0200 Subject: [PATCH 30/40] =?UTF-8?q?=F0=9F=93=9D=20New=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/ping.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/ping.js b/commands/ping.js index 64cc37f..461174d 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -4,6 +4,6 @@ const Discord = require("discord.js") exports.run = async (client, message, args) => { //Message - message.channel.send(`Ping : ${client.ws.ping} ${emotes.success}`) + message.channel.send(`Ping : ${client.ws.ping} ms ${emotes.success}`) } From 2773bcd114d760dd3ed5329c4d53f6cb6943b57e Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:21:39 +0200 Subject: [PATCH 31/40] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 962cb3a..20b26df 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,7 @@ Emojis are already defined by default but you can modify them if you wish. Go to the console and type this : ``` -npm init -npm i (name of each missing module) +npm i ``` All you have to do is turn on your bot ! From 76862b4ee699fb19275de1ed39d7def9b0da331d Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:22:41 +0200 Subject: [PATCH 32/40] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 20b26df..1ad6f9e 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,16 @@ Go to the console and type this : npm i ``` +To start the bot : + +``` +#With Node +node index.js + +#With pm2 +pm2 start index.js --name "MusicBot" +``` + All you have to do is turn on your bot ! ### 🎵 Music commands From 1084d0cedf0c24246dfb416175c5775fffd98bf9 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:23:18 +0200 Subject: [PATCH 33/40] =?UTF-8?q?=F0=9F=93=9D=20New=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From e3da87084a66cc47d1805d70ca0edf6d06b7d62a Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 19:02:39 +0200 Subject: [PATCH 34/40] =?UTF-8?q?=F0=9F=94=92=20Fix=20bug=20with=20prefix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/help.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/help.js b/commands/help.js index c3c773b..e999ab5 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,3 +1,4 @@ +const config = require ("../config/bot.json"); const emotes = require ("../config/emojis.json"); const Discord = require("discord.js") @@ -8,7 +9,7 @@ exports.run = async (client, message, args) => { .setDescription("Find the list of commands available on this panel.") .addField("**Music**", "`play`, `pause`, `resume`, `queue`, `clear-queue`, `shuffle`, `np`, `loop`, `volume`, `skip`, `stop`") .addField("**Filters**", "`bassboost`, `tremolo`, `vibrato`, `treble`, `8D`, `normalizer`, `surrounding`, `nightcore`, `vaporwave`, `superequalizer`, `phaser`, `reverse`, `pulsator`") - .setFooter("To use filters, ^filter (the filter). Example : ^filter 8D.") + .setFooter(`To use filters, ${config.prefix}filter (the filter). Example : ${config.prefix}filter 8D.`) .setColor("ORANGE") //Message From d5be74cf6c28574be2e8952542e1580863fdfa38 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 19:05:37 +0200 Subject: [PATCH 35/40] =?UTF-8?q?=F0=9F=94=92=20Fix=20bug=20with=20volume?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/volume.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/volume.js b/commands/volume.js index d249e28..d497126 100644 --- a/commands/volume.js +++ b/commands/volume.js @@ -17,9 +17,11 @@ exports.run = async (client, message, args) => { if(100 < args[0]) return message.channel.send(`Please enter a valid number ${emotes.error}`) if(args[0] <=0) return message.channel.send(`Please enter a valid number ${emotes.error}`) - //Cannot put (-) or (+) - if(message.content.includes(".")) return message.channel.send(`Please enter a valid number ${emotes.error}`) + //Cannot put (-), (+), (,) or (.) + if(message.content.includes("-")) return message.channel.send(`Please enter a valid number ${emotes.error}`) if(message.content.includes("+")) return message.channel.send(`Please enter a valid number ${emotes.error}`) + if(message.content.includes(",")) return message.channel.send(`Please enter a valid number ${emotes.error}`) + if(message.content.includes(".")) return message.channel.send(`Please enter a valid number ${emotes.error}`) //Set volume client.player.setVolume(message.guild.id, parseInt(args.join(" "))); From a34c4ce0a64aa24166521b1f6d407bc8ea33392d Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Wed, 24 Jun 2020 19:11:58 +0200 Subject: [PATCH 36/40] :sparkles: Support playlists --- commands/play.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/commands/play.js b/commands/play.js index b70894d..52a2bec 100644 --- a/commands/play.js +++ b/commands/play.js @@ -15,14 +15,22 @@ exports.run = async (client, message, args) => { if(aTrackIsAlreadyPlaying){ // Add the track to the queue - const track = await client.player.addToQueue(message.guild.id, args.join(" ")); - message.channel.send(`Track ${track.name} added to queue ${emotes.music}`); + const result = await client.player.addToQueue(message.guild.id, args[0]); + if(result.type === 'playlist'){ + message.channel.send(`${result.tracks.length} songs added to the queue ${emotes.music}`); + } else { + message.channel.send(`${result.name} added to the queue ${emotes.music}`); + } } else { // Else, play the song - const song = await client.player.play(message.member.voice.channel, args.join(" ")); - message.channel.send(`Currently playing ${song.name} ${emotes.music}`); + const result = await client.player.play(message.member.voice.channel, args.join(" ")); + if(result.type === 'playlist'){ + message.channel.send(`${result.tracks.length} songs added to the queue ${emotes.music}\nCurrently playing **${result.tracks[0].name}**!`); + } else { + message.channel.send(`Currently playing ${result.name} ${emotes.music}`); + } const queue = client.player.getQueue(message.guild.id) From 965c6ba9a9aff73e8daf486ce414667933628b66 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 19:16:12 +0200 Subject: [PATCH 37/40] =?UTF-8?q?=E2=9C=A8=20Support=20playlists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/play.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/play.js b/commands/play.js index 52a2bec..f8b1d41 100644 --- a/commands/play.js +++ b/commands/play.js @@ -27,7 +27,7 @@ exports.run = async (client, message, args) => { // Else, play the song const result = await client.player.play(message.member.voice.channel, args.join(" ")); if(result.type === 'playlist'){ - message.channel.send(`${result.tracks.length} songs added to the queue ${emotes.music}\nCurrently playing **${result.tracks[0].name}**!`); + message.channel.send(`${result.tracks.length} songs added to the queue ${emotes.music}\nCurrently playing ${result.tracks[0].name} !`); } else { message.channel.send(`Currently playing ${result.name} ${emotes.music}`); } From 50f655386c9c98fbc098a78494f32329f6ad3b98 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Thu, 25 Jun 2020 18:07:21 +0200 Subject: [PATCH 38/40] :fire: Remove useless dependency --- index.js | 3 +-- package.json | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index f4d2b09..1f422ff 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,5 @@ //Modules const Discord = require("discord.js"); -const Enmap = require('enmap') const fs = require("fs"); //New client @@ -28,7 +27,7 @@ fs.readdir("./events/", (err, files) => { }); //New commands -client.commands = new Enmap(); +client.commands = new Discord.Collection(); //Commands fs.readdir("./commands/", (err, files) => { diff --git a/package.json b/package.json index f956e80..37c47fa 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "dependencies": { "@discordjs/opus": "^0.3.2", "discord-player": "github:Androz2091/discord-player#develop", - "discord.js": "^12.2.0", - "enmap": "^5.3.1" + "discord.js": "^12.2.0" } } From 2c6973890816b969c97a9165077f7246149931d0 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Thu, 25 Jun 2020 18:33:05 +0200 Subject: [PATCH 39/40] :zap: Add error message when the song can't be played --- commands/play.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commands/play.js b/commands/play.js index f8b1d41..a84bd9c 100644 --- a/commands/play.js +++ b/commands/play.js @@ -16,6 +16,8 @@ exports.run = async (client, message, args) => { // Add the track to the queue const result = await client.player.addToQueue(message.guild.id, args[0]); + if(!result) return message.channel.send(`This song provider is not supported...`); + if(result.type === 'playlist'){ message.channel.send(`${result.tracks.length} songs added to the queue ${emotes.music}`); } else { @@ -25,7 +27,9 @@ exports.run = async (client, message, args) => { } else { // Else, play the song - const result = await client.player.play(message.member.voice.channel, args.join(" ")); + const result = await client.player.play(message.member.voice.channel, args.join(" ")).catch(() => {}); + if(!result) return message.channel.send(`This song provider is not supported...`); + if(result.type === 'playlist'){ message.channel.send(`${result.tracks.length} songs added to the queue ${emotes.music}\nCurrently playing ${result.tracks[0].name} !`); } else { From ae9fdc0e8a6a20043c471fd381d308d09a6f76c1 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Sat, 27 Jun 2020 17:42:35 +0200 Subject: [PATCH 40/40] =?UTF-8?q?=F0=9F=93=9D=20New=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/help.js | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/help.js b/commands/help.js index e999ab5..552c2b7 100644 --- a/commands/help.js +++ b/commands/help.js @@ -9,6 +9,7 @@ exports.run = async (client, message, args) => { .setDescription("Find the list of commands available on this panel.") .addField("**Music**", "`play`, `pause`, `resume`, `queue`, `clear-queue`, `shuffle`, `np`, `loop`, `volume`, `skip`, `stop`") .addField("**Filters**", "`bassboost`, `tremolo`, `vibrato`, `treble`, `8D`, `normalizer`, `surrounding`, `nightcore`, `vaporwave`, `superequalizer`, `phaser`, `reverse`, `pulsator`") + .addField("**Informations**", "`ping`") .setFooter(`To use filters, ${config.prefix}filter (the filter). Example : ${config.prefix}filter 8D.`) .setColor("ORANGE")