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/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}**`); }; 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 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:" } 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 diff --git a/package.json b/package.json index 164c62a..475bb05 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" }