Ask coding questions

← Back to all posts
Why retryCounter is added 2 times "1" instead of just 1 time?
Axel1672 (5)

var verifSent = 0;

var retryCounter = 1;

client.on('message', (message) => {
if (message.content.toLowerCase() === Prefix + 'verify' && verifSent == 1 && message.member.roles.cache.find(role => role.name != "Verified")) {
message.channel.send("<@" + message.author.id + ">" + " You already have a pending verification");
}
else if (message.content.toLowerCase() === Prefix + 'verify' && verifSent != 1 && message.member.roles.cache.find(role => role.name != "Verified")) {
if (message.channel.type === "text") {
if (message.channel.id == 829952301317750804) {
var verificationMessage = "";
var x = 0
while (x < 6) {
verificationMessage += randomChars[Math.floor(Math.random() * randomChars.length)]
x = x + 1
}
message.author.send("Here is your verification message: " + verificationMessage).then(MessageSent)
.catch(() => {
message.channel.send("<@" + message.author.id + ">" + " I couldn't send you the verification message");
})
function MessageSent() {
message.channel.send("<@" + message.author.id + ">" + " I have sent the verification message to your DMs");
verifSent = 1
}
}
}
client.on('message', (message) => {
if (message.channel.type === "dm" && retryCounter <= 3 && message.content == verificationMessage) {
message.author.send("Verification complete!");
verifSent = 1
}
else if (message.channel.type === "dm" && retryCounter <= 3 && message.content != verificationMessage) {
message.author.send("Incorrect please try again | " + retryCounter + "/3");
retryCounter = retryCounter + 1
}
})
}
});