2022-01-13 00:56:24 +05:00
|
|
|
const Command = require("../../base/Command"),
|
2022-01-04 02:18:28 +05:00
|
|
|
Discord = require("discord.js");
|
|
|
|
|
|
|
|
class Announcement extends Command {
|
|
|
|
constructor(client) {
|
|
|
|
super(client, {
|
|
|
|
name: "announcement",
|
|
|
|
dirname: __dirname,
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: true,
|
|
|
|
aliases: ["ann"],
|
|
|
|
memberPermissions: ["MENTION_EVERYONE"],
|
|
|
|
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
|
|
|
|
nsfw: false,
|
|
|
|
ownerOnly: false,
|
|
|
|
cooldown: 1000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async run(message, args, data) {
|
|
|
|
const text = args.join(" ");
|
|
|
|
if (!text) return message.error("moderation/announcement:MISSING_TEXT");
|
|
|
|
if (text.length > 1030) return message.error("moderation/announcement:TOO_LONG");
|
|
|
|
|
2022-01-04 21:16:52 +05:00
|
|
|
let mention = null;
|
2022-02-25 00:56:32 +05:00
|
|
|
const msg = await message.sendT("moderation/announcement:MENTION_PROMPT");
|
2022-01-05 00:24:57 +05:00
|
|
|
|
|
|
|
const filter = m => m.author.id === message.author.id;
|
|
|
|
const collector = new Discord.MessageCollector(message.channel, {
|
|
|
|
filter,
|
2022-01-04 02:18:28 +05:00
|
|
|
time: 240000
|
|
|
|
});
|
|
|
|
|
|
|
|
collector.on("collect", async (tmsg) => {
|
|
|
|
if (tmsg.content.toLowerCase() === message.translate("common:NO").toLowerCase()) {
|
|
|
|
tmsg.delete();
|
|
|
|
msg.delete();
|
|
|
|
collector.stop(true);
|
2022-02-15 01:40:18 +05:00
|
|
|
|
2022-02-15 01:42:00 +05:00
|
|
|
if (message.deletable) message.delete();
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
if (tmsg.content.toLowerCase() === message.translate("common:YES").toLowerCase()) {
|
|
|
|
tmsg.delete();
|
|
|
|
msg.delete();
|
2022-02-15 01:40:18 +05:00
|
|
|
const tmsg1 = await message.channel.send(message.translate("moderation/announcement:MENTION_TYPE_PROMPT"));
|
2022-01-05 00:24:57 +05:00
|
|
|
|
|
|
|
const filter = m => m.author.id === message.author.id;
|
|
|
|
const c = new Discord.MessageCollector(message.channel, {
|
|
|
|
filter,
|
2022-01-04 02:18:28 +05:00
|
|
|
time: 60000
|
|
|
|
});
|
|
|
|
c.on("collect", (m) => {
|
|
|
|
if (m.content.toLowerCase() === "here") {
|
|
|
|
mention = "@here";
|
|
|
|
tmsg1.delete();
|
|
|
|
m.delete();
|
|
|
|
collector.stop(true);
|
|
|
|
c.stop(true);
|
|
|
|
} else if (m.content.toLowerCase() === "everyone") {
|
|
|
|
mention = "@everyone";
|
|
|
|
tmsg1.delete();
|
|
|
|
m.delete();
|
|
|
|
collector.stop(true);
|
|
|
|
c.stop(true);
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
});
|
2022-02-15 01:40:18 +05:00
|
|
|
|
2022-01-04 02:18:28 +05:00
|
|
|
c.on("end", (collected, reason) => {
|
|
|
|
if (reason === "time") return message.error("misc:TIMES_UP");
|
|
|
|
});
|
2022-02-15 01:40:18 +05:00
|
|
|
|
2022-02-15 01:42:00 +05:00
|
|
|
if (message.deletable) message.delete();
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
collector.on("end", (collected, reason) => {
|
|
|
|
if (reason === "time") return message.error("misc:TIMES_UP");
|
|
|
|
|
|
|
|
const embed = new Discord.MessageEmbed()
|
2022-01-05 00:24:57 +05:00
|
|
|
.setAuthor({
|
|
|
|
name: message.translate("moderation/announcement:TITLE")
|
|
|
|
})
|
2022-01-04 02:18:28 +05:00
|
|
|
.setColor(data.config.embed.color)
|
2022-01-05 00:24:57 +05:00
|
|
|
.setFooter({
|
|
|
|
text: message.author.tag
|
|
|
|
})
|
2022-01-04 02:18:28 +05:00
|
|
|
.setTimestamp()
|
|
|
|
.setDescription(text);
|
|
|
|
|
2022-01-05 00:24:57 +05:00
|
|
|
message.channel.send({
|
|
|
|
content: mention,
|
|
|
|
embeds: [embed]
|
|
|
|
});
|
2022-01-04 02:18:28 +05:00
|
|
|
});
|
|
|
|
}
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
module.exports = Announcement;
|