1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 04:31:56 +00:00

Update blacklist.js

This commit is contained in:
MatteZ02 2020-06-29 20:48:44 +03:00
parent 83b56b73a0
commit 0e25ac5752

View File

@ -3,107 +3,114 @@ const discord = require("discord.js");
module.exports = { module.exports = {
name: "blacklist", name: "blacklist",
async execute(msg, args, client) { async execute(msg, args, client) {
if (args[2] === "add") { let embed;
if (msg.mentions.channels.first()) { switch (args[2]) {
if ( case "add":
client.global.db.guilds[msg.guild.id].blacklist.includes( if (msg.mentions.channels.first()) {
msg.mentions.channels.first().id if (
client.global.db.guilds[msg.guild.id].blacklist.includes(
msg.mentions.channels.first().id
)
) )
return msg.channel.send(client.messages.channelAlreadyBlackListed);
} else if (
client.global.db.guilds[msg.guild.id].blacklist.includes(args[3])
) )
return msg.channel.send(client.messages.channelAlreadyBlackListed); return msg.channel.send(client.messages.channelAlreadyBlackListed);
} else if (
client.global.db.guilds[msg.guild.id].blacklist.includes(args[3])
)
return msg.channel.send(client.messages.channelAlreadyBlackListed);
if (
!msg.guild.channels.cache.get(args[3]) &&
!msg.mentions.channels.first()
)
return msg.channel.send(client.messages.idOrMentionChannel);
if (msg.mentions.channels.first()) {
client.global.db.guilds[msg.guild.id].blacklist.push(
msg.mentions.channels.first().id
);
let message;
message = client.messages.channelAdded.replace(
"%CHANNEL%",
msg.mentions.channels.first().name
);
msg.channel.send(message);
} else {
client.global.db.guilds[msg.guild.id].blacklist.push(args[3]);
let message;
message = client.messages.channelAdded.replace(
"%CHANNEL%",
msg.guild.channels.cache.get(args[3]).name
);
msg.channel.send(message);
}
} else if (args[2] === "remove") {
if (msg.mentions.channels.first()) {
if ( if (
!client.global.db.guilds[msg.guild.id].blacklist.includes( !msg.guild.channels.cache.get(args[3]) &&
msg.mentions.channels.first().id !msg.mentions.channels.first()
)
) )
return msg.channel.send(client.messages.channelNotBlackListed); return msg.channel.send(client.messages.idOrMentionChannel);
if ( if (msg.mentions.channels.first()) {
client.global.db.guilds[msg.guild.id].blacklist.indexOf( client.global.db.guilds[msg.guild.id].blacklist.push(
msg.mentions.channels.first().id msg.mentions.channels.first().id
) !== -1
) {
client.global.db.guilds[msg.guild.id].blacklist.splice(
client.global.db.guilds[msg.guild.id].blacklist.indexOf(
msg.mentions.channels.first().id
),
1
); );
let message; let message;
message = client.messages.channelRemoved.replace( message = client.messages.channelAdded.replace(
"%CHANNEL%", "%CHANNEL%",
msg.mentions.channels.first().name msg.mentions.channels.first().name
); );
} msg.channel.send(message);
} else { } else {
if (!client.global.db.guilds[msg.guild.id].blacklist.includes(args[3])) client.global.db.guilds[msg.guild.id].blacklist.push(args[3]);
return msg.channel.send(client.messages.channelNotBlackListed);
if (
client.global.db.guilds[msg.guild.id].blacklist.indexOf(args[3]) !==
-1
) {
client.global.db.guilds[msg.guild.id].blacklist.splice(
client.global.db.guilds[msg.guild.id].blacklist.indexOf(args[3]),
1
);
let message; let message;
message = client.messages.channelRemoved.replace( message = client.messages.channelAdded.replace(
"%CHANNEL%", "%CHANNEL%",
msg.guild.channels.cache.get(args[3]).name msg.guild.channels.cache.get(args[3]).name
); );
msg.channel.send(message); msg.channel.send(message);
} }
} break;
} else if (args[2] === "list") { case "remove":
const embed = new discord.MessageEmbed() if (msg.mentions.channels.first()) {
.setTitle(client.messages.blacklistTitle) if (
.setDescription( !client.global.db.guilds[msg.guild.id].blacklist.includes(
`${client.global.db.guilds[msg.guild.id].blacklist msg.mentions.channels.first().id
)
)
return msg.channel.send(client.messages.channelNotBlackListed);
if (
client.global.db.guilds[msg.guild.id].blacklist.indexOf(
msg.mentions.channels.first().id
) !== -1
) {
client.global.db.guilds[msg.guild.id].blacklist.splice(
client.global.db.guilds[msg.guild.id].blacklist.indexOf(
msg.mentions.channels.first().id
),
1
);
let message;
message = client.messages.channelRemoved.replace(
"%CHANNEL%",
msg.mentions.channels.first().name
);
msg.channel.send(message);
}
} else {
if (!client.global.db.guilds[msg.guild.id].blacklist.includes(args[3]))
return msg.channel.send(client.messages.channelNotBlackListed);
if (
client.global.db.guilds[msg.guild.id].blacklist.indexOf(args[3]) !==
-1
) {
client.global.db.guilds[msg.guild.id].blacklist.splice(
client.global.db.guilds[msg.guild.id].blacklist.indexOf(args[3]),
1
);
let message;
message = client.messages.channelRemoved.replace(
"%CHANNEL%",
msg.guild.channels.cache.get(args[3]).name
);
msg.channel.send(message);
}
}
break;
case "list":
embed = new discord.MessageEmbed()
.setTitle(client.messages.blacklistTitle)
.setDescription(
`${client.global.db.guilds[msg.guild.id].blacklist
.map((c) => `**-** <#${c}>`) .map((c) => `**-** <#${c}>`)
.join("\n")}` .join("\n")}`
) )
.setColor(client.config.embedColor); .setColor(client.config.embedColor);
msg.channel.send(embed); msg.channel.send(embed);
} else { break;
const embed = new discord.MessageEmbed() case undefined:
.setTitle(client.messages.blacklistTitle) embed = new discord.MessageEmbed()
.addField("add", "Add a channel to the blacklist. (ID or mention)") .setTitle(client.messages.blacklistTitle)
.addField( .addField("add", "Add a channel to the blacklist. (ID or mention)")
"remove", .addField(
"Remove a channel from the blacklist. (ID or mention)" "remove",
) "Remove a channel from the blacklist. (ID or mention)"
.addField("list", "List the currently blacklisted channels.") )
.setColor(client.config.embedColor); .addField("list", "List the currently blacklisted channels.")
msg.channel.send(embed); .setColor(client.config.embedColor);
msg.channel.send(embed);
break;
} }
}, },
}; };