JaBa/commands/Fun/choice.js

39 lines
1,002 B
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Choice extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "choice",
dirname: __dirname,
enabled: true,
guildOnly: false,
2021-12-26 19:29:37 +05:00
aliases: ["random"],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
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,
cooldown: 2000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args) {
2021-12-10 21:39:54 +05:00
// Gets the answers by spliting on "/"
const answers = args.join(" ").split("/");
if (answers.length < 2) return message.error("fun/choice:MISSING");
if (answers.some(answer => !answer)) return message.error("fun/choice:EMPTY");
const m = await message.sendT("fun/choice:PROGRESS", null, false, false, "loading");
setTimeout(() => {
2021-12-26 19:29:37 +05:00
m.success("fun/choice:DONE", null, {
edit: true
});
2021-12-10 21:39:54 +05:00
const result = answers[parseInt(Math.floor(Math.random() * answers.length))];
2022-01-04 00:35:11 +05:00
message.channel.send({
content: "```" + result + "```"
});
2021-12-10 21:39:54 +05:00
}, 1500);
}
};
module.exports = Choice;