Bug fixes & update (v2.0.0)

This commit is contained in:
Zerio
2020-11-15 18:52:02 +01:00
committed by GitHub
parent 7def900256
commit aeabedf100

View File

@@ -1,41 +1,27 @@
const emotes = require ("../config/emojis.json");
const emotes = require("../config/emojis.json");
const filters = require("../config/filters.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 (!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}`);
if (!client.player.getQueue(message)) return message.channel.send(`No songs currently playing ${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 he can't find the filter
if(!filterToUpdate) return message.channel.send(`This filter doesn't exist ${emotes.error}`);
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 queueFilters = client.player.getQueue(message).filters
const filtersUpdated = {};
filtersUpdated[filterRealName] = queueFilters[filterRealName] ? false : true;
client.player.setFilters(message.guild.id, filtersUpdated);
client.player.setFilters(message, filtersUpdated);
if(filtersUpdated[filterRealName]) {
if (filtersUpdated[filterRealName]) message.channel.send(`I'm **adding** the filter to the music, please wait... Note : the longer the music is, the longer this will take ${emotes.music}`);
else message.channel.send(`I'm **disabling** the filter on the music, please wait... Note : the longer the music is playing, the longer this will take ${emotes.music}`);
//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 this will take ${emotes.music}`);
} else {
//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 this will take ${emotes.music}`);
}
}
};