JaBa/commands/Administration/ignore.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Ignore extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "ignore",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["ig"],
2021-12-26 19:29:37 +05:00
memberPermissions: ["MANAGE_GUILD"],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 1000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-10 21:39:54 +05:00
const channel = message.mentions.channels.filter((ch) => ch.type === "text" && ch.guild.id === message.guild.id).first();
if (!channel) return message.error("misc:INVALID_CHANNEL");
const ignored = data.guild.ignoredChannels.includes(channel.id);
if (ignored) {
data.guild.ignoredChannels = data.guild.ignoredChannels.filter((ch) => ch !== channel.id);
data.guild.save();
2021-12-26 19:29:37 +05:00
return message.success("administration/ignore:ALLOWED", {
channel: channel.toString()
});
2021-12-10 21:39:54 +05:00
} else if (!ignored) {
data.guild.ignoredChannels.push(channel.id);
data.guild.save();
2021-12-26 19:29:37 +05:00
return message.success("administration/ignore:IGNORED", {
channel: channel.toString()
});
2021-12-10 21:39:54 +05:00
};
}
};
module.exports = Ignore;