2021-12-10 21:39:54 +05:00
|
|
|
const Command = require("../../base/Command.js"),
|
|
|
|
Discord = require("discord.js");
|
|
|
|
|
|
|
|
class Poll extends Command {
|
2021-12-26 19:29:37 +05:00
|
|
|
constructor(client) {
|
2021-12-10 21:39:54 +05:00
|
|
|
super(client, {
|
|
|
|
name: "poll",
|
|
|
|
dirname: __dirname,
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: true,
|
|
|
|
aliases: [],
|
2021-12-29 01:57:02 +05:00
|
|
|
memberPermissions: ["MANAGE_MESSAGES"],
|
2021-12-26 19:29:37 +05:00
|
|
|
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
|
2021-12-10 21:39:54 +05:00
|
|
|
nsfw: false,
|
|
|
|
ownerOnly: false,
|
2021-12-22 17:32:50 +05:00
|
|
|
cooldown: 2000
|
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 question = args.join(" ");
|
2021-12-11 01:11:50 +05:00
|
|
|
if (!question) return message.error("moderation/poll:MISSING_QUESTION");
|
2021-12-10 21:39:54 +05:00
|
|
|
|
|
|
|
message.delete().catch(() => {});
|
|
|
|
|
|
|
|
let mention = "";
|
|
|
|
const msg = await message.sendT("moderation/announcement:MENTION_PROMPT");
|
2021-12-26 19:29:37 +05:00
|
|
|
const collector = new Discord.MessageCollector(message.channel, (m) => m.author.id === message.author.id, {
|
|
|
|
time: 240000
|
|
|
|
});
|
|
|
|
|
2021-12-10 21:39:54 +05:00
|
|
|
collector.on("collect", async (tmsg) => {
|
2021-12-11 01:11:50 +05:00
|
|
|
if (tmsg.content.toLowerCase() === message.translate("common:NO").toLowerCase()) {
|
2021-12-10 21:39:54 +05:00
|
|
|
tmsg.delete();
|
|
|
|
msg.delete();
|
|
|
|
collector.stop(true);
|
2021-12-11 01:11:50 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
if (tmsg.content.toLowerCase() === message.translate("common:YES").toLowerCase()) {
|
2021-12-10 21:39:54 +05:00
|
|
|
tmsg.delete();
|
|
|
|
msg.delete();
|
|
|
|
const tmsg1 = await message.sendT("moderation/announcement:MENTION_TYPE_PROMPT");
|
2021-12-26 19:29:37 +05:00
|
|
|
const c = new Discord.MessageCollector(message.channel, (m) => m.author.id === message.author.id, {
|
|
|
|
time: 60000
|
|
|
|
});
|
|
|
|
|
2021-12-10 21:39:54 +05:00
|
|
|
c.on("collect", (m) => {
|
2021-12-11 01:11:50 +05:00
|
|
|
if (m.content.toLowerCase() === "here") {
|
2021-12-10 21:39:54 +05:00
|
|
|
mention = "@here";
|
|
|
|
tmsg1.delete();
|
|
|
|
m.delete();
|
|
|
|
collector.stop(true);
|
|
|
|
c.stop(true);
|
2021-12-11 01:11:50 +05:00
|
|
|
} else if (m.content.toLowerCase() === "every") {
|
2021-12-10 21:39:54 +05:00
|
|
|
mention = "@everyone";
|
|
|
|
tmsg1.delete();
|
|
|
|
m.delete();
|
|
|
|
collector.stop(true);
|
|
|
|
c.stop(true);
|
2021-12-11 01:11:50 +05:00
|
|
|
};
|
2021-12-10 21:39:54 +05:00
|
|
|
});
|
|
|
|
c.on("end", (collected, reason) => {
|
2021-12-26 19:29:37 +05:00
|
|
|
if (reason === "time") return message.error("misc:TIMES_UP");
|
2021-12-10 21:39:54 +05:00
|
|
|
});
|
2021-12-11 01:11:50 +05:00
|
|
|
};
|
2021-12-10 21:39:54 +05:00
|
|
|
});
|
2021-12-11 01:11:50 +05:00
|
|
|
|
2021-12-10 21:39:54 +05:00
|
|
|
collector.on("end", (collected, reason) => {
|
2021-12-26 19:29:37 +05:00
|
|
|
if (reason === "time") return message.error("misc:TIMES_UP");
|
2021-12-11 01:11:50 +05:00
|
|
|
|
2021-12-10 21:39:54 +05:00
|
|
|
const success = this.client.customEmojis.success.split(":")[1];
|
|
|
|
const error = this.client.customEmojis.error.split(":")[1];
|
|
|
|
|
|
|
|
const emojis = [
|
|
|
|
this.client.emojis.cache.find((e) => e.name === success),
|
|
|
|
this.client.emojis.cache.find((e) => e.name === error)
|
|
|
|
];
|
|
|
|
|
|
|
|
const embed = new Discord.MessageEmbed()
|
|
|
|
.setAuthor(message.translate("moderation/poll:TITLE"))
|
|
|
|
.setColor(data.config.embed.color)
|
2021-12-26 19:29:37 +05:00
|
|
|
.addField(question, message.translate("moderation/poll:REACT", {
|
|
|
|
success: emojis[0].toString(),
|
|
|
|
error: emojis[1].toString()
|
|
|
|
}));
|
2021-12-11 01:11:50 +05:00
|
|
|
|
2021-12-10 21:39:54 +05:00
|
|
|
message.channel.send(mention, embed).then(async (m) => {
|
|
|
|
await m.react(emojis[0]);
|
|
|
|
await m.react(emojis[1]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2021-12-11 01:11:50 +05:00
|
|
|
};
|
2021-12-10 21:39:54 +05:00
|
|
|
|
|
|
|
module.exports = Poll;
|