S
S
SlyuJoke2021-06-25 10:57:37
Node.js
SlyuJoke, 2021-06-25 10:57:37

DiscordJS | How to check the nickname for the presence of caps in it?

Good day, dear coders.
Please help write code that would initially get all server nicknames, and then check these nicknames for the presence of upper case in it.
And if the nickname contains more than 50% of uppercase letters, then the bot would output all these nicknames to the console.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
ParaBellum577, 2021-06-25
@SlyuJoke

You need a method by which you can pull data from the server, then you can check nicknames in this way.

const string = 'AnaStAsIA'
const upper = []:
const lower = [];
for(i = 0; i < string.length; i++) {
    let character = "";
    character = string.charAt(i);
    if (character == character.toUpperCase()) {
    upper.push(character);
} else {
    lower.push(character);
}
}
if(upper.length > lower.length) {
do something.....
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question