#Command that takes a user argument from a mention
1 messages · Page 1 of 1 (latest)
Yup hi
I'm just trying to get a user from a mention/id of someone
Is there anyway I can do that without checking for both cases
i.e. if it's not a mention then I check if it's an Id
so for example something like
"!greeting @some_person" and it gets their id?
wait, so if there's a mention get that id, else get the author id?
no
else get the ID passed into with the message
in which I have already isolated as arg
Use ternary operator <Message>.mentions.users.first() returns undefined if theres no mention
<:_:818272565419573308> Conditional (ternary) operator
The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is truthy followed by a colon (:), and finally the expression to execute if the condition is falsy. This operator is frequently used as an alternative to an if...else statement.
ohhhhh right
Sorry I was so confused there for a second. Cheers Lawrster
@hollow dirge You also mentioned that <Client>.users.fetch(id) can be used to get the User from the ID, but it returns a promise. So how would I implement it into a ternary operator as message.mentions.user.first() does not
(await <Client>.users.fetch(id))
but then it's not in an async function so how would that work
Should I make a helper function for that