nyx/commands/Owner/try.js

58 lines
1.8 KiB
JavaScript
Raw Normal View History

2021-06-12 12:53:51 +02:00
const { Client, Message, MessageEmbed } = require("discord.js");
module.exports = {
name: "auth",
run: async (client, message, args) => {
const random = client.function.rndint(100000, 999999);
let ed;
const questions = [
`Please enter the following code to authenicate\n\n\`${random}\``,
];
let collectCounter = 0;
let endCounter = 0;
const filter = m => m.author.id === message.author.id;
2021-09-06 12:38:25 +02:00
message.reply("Please check your DM.");
2021-06-12 12:53:51 +02:00
try {
const appStart = await message.author.send(
new MessageEmbed()
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle("One-Time Password")
.setDescription(questions[collectCounter++])
.setColor(client.color)
2021-06-24 09:53:19 +02:00
.setFooter(`Made by ${client.author}`)
2021-06-12 12:53:51 +02:00
.setTimestamp()
);
const channel = appStart.channel;
const collector = channel.createMessageCollector(filter);
collector.on("collect", () => {
collector.stop("fulfilled");
});
collector.on("end", (collected, reason) => {
if (reason === "fulfilled") {
const msss = collected.map(msg => {
if (msg.content === `${random}`) {
message.author.send(
new MessageEmbed()
.setDescription(`Success`)
.setTimestamp()
.setColor("GREEN")
2021-06-24 09:53:19 +02:00
.setFooter(`Made by ${client.author}`)
2021-06-12 12:53:51 +02:00
);
} else {
message.author.send(
new MessageEmbed()
.setDescription(`Failed\nPlease try again.`)
.setTimestamp()
.setColor("RED")
2021-06-24 09:53:19 +02:00
.setFooter(`Made by ${client.author}`)
2021-06-12 12:53:51 +02:00
);
}
});
}
});
} catch (err) {
2021-07-13 05:17:39 +02:00
console.log(err);
2021-06-12 12:53:51 +02:00
}
},
};