#Message.mentions.members.first() Not Working

38 messages · Page 1 of 1 (latest)

heavy vector
#

Why Message.mentions.members.first() Returns In this command Example:
!update @heavy vector --> User Obj

if Putting 2 space: !update @heavy vector --> Return All the Guild members

fast aspen
#

provide code and logged values.

heavy vector
fast aspen
#

Looks like your args is fishy and thus fetches all members.

green quarry
fast aspen
#

I assume you split by spaces, thus args[0] not being what you expect it to be

heavy vector
#

Basicaly the command should work like this:

!update UserID (Should Enter on first condition) Since is a number And Is not Nan
!update @sterile scarab It's a User Object and should enter on second condition and the code should take first User Pinged.

fast aspen
#

an empty string would return true in your case.

#

thus fetching all members

#

sou you should also check if args[0] isn't an empty string

green quarry
#

@heavy vector Show us how you are defining args

heavy vector
#

Ok

fast aspen
#

How they define args is irrelevant

green quarry
#

It is tho

#

Because if they use regex

fast aspen
#

how does regex matter here

green quarry
#

If you use two spaces args would still be correct with regex

fast aspen
#

you split args by space, everything else wouldn't make sense
thus with a double space one entry is an empty string

#

and an empty string isn't considered not a number

heavy vector
#

First Case (With 1 Space)

[ '@heavy vector' ]

Second Case (With 2 Space)

[ '', '@heavy vector' ]
#

that should not be relevant im just taking User

fast aspen
#

you should also check if args[0] isn't an empty string

heavy vector
#

from mentions

green quarry
heavy vector
#

Sorry for Language

#

(It means) Not Args

fast aspen
#

again, check if args[0] isn't an empty string

#

nothing more needed

heavy vector
#

Ok, where i should check this?

fast aspen
#

where you check if its a number

#

or you just remove all empty strings in the array

heavy vector
subtle kindleBOT
#

Checking for things to not be equal in JavaScript:

- if (!yourVariable === yourOtherVariable) // !yourVariable is coerced to a boolean value
+ if (yourVariable !== yourOtherVariable) // checks that one is not equal to the other

• Comparison operators in JavaScript: learn more

heavy vector
#

that's what i send

fast aspen
#

thats not what you send

#

read again

heavy vector