Merge pull request #9 from Androz2091/v2

This commit is contained in:
Androz
2020-06-24 14:14:30 +02:00
committed by GitHub
11 changed files with 128 additions and 24 deletions

41
commands/filter.js Normal file
View File

@@ -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: []
};

View File

@@ -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}**`);
};

View File

@@ -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}**`);
};

View File

@@ -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...');
});
}
};

View File

@@ -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')
));
};

View File

@@ -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}**`);
};

View File

@@ -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}**`);
};

35
commands/w-filters.js Normal file
View File

@@ -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: []
};

View File

@@ -1,6 +1,6 @@
{
"music": ":musical_note:",
"queue": ":bar_chart:",
"error": ":tools:",
"error": ":x:",
"success": ":white_check_mark:"
}

15
config/filters.json Normal file
View File

@@ -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"
}

View File

@@ -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"
}