✨ Add filters management commands
This commit is contained in:
@@ -2,18 +2,23 @@ const emotes = require ("../config/emojis.json");
|
|||||||
const filters = require("../config/filters.json");
|
const filters = require("../config/filters.json");
|
||||||
const Discord = require("discord.js")
|
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];
|
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());
|
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 filterRealName = Object.keys(filters).find((f) => filters[f] === filterToUpdate);
|
||||||
|
|
||||||
const queueFilters = client.player.getQueue(message.guild.id).filters
|
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;
|
filtersUpdated[filterRealName] = queueFilters[filterRealName] ? false : true;
|
||||||
client.player.setFilters(message.guild.id, filtersUpdated);
|
client.player.setFilters(message.guild.id, filtersUpdated);
|
||||||
|
|
||||||
if(filtersUpdated[filterRealName]){
|
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:")
|
//The bot adds the filter on the music
|
||||||
.setColor("BLUE");
|
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}`);
|
||||||
message.channel.send(pleaseWait);
|
|
||||||
} else {
|
} 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:`)
|
//The bot removes the filter from the music
|
||||||
.setColor("BLUE");
|
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}`);
|
||||||
message.channel.send(pleaseWait);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.config = {
|
|
||||||
name: "filter",
|
|
||||||
aliases: []
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user