Check if optional argument in commnd was provided

Hey, I have a command called /stats It will provide the stats for the user who entered the command, the command also has a optional argument (user mention) with which the user can get the stats of another user. How can I check if the argument is provided because now I just get an error when only the /stats command is entered
4 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
MrMythical
MrMythical3y ago
is null if not entered
Schlaumeyer
SchlaumeyerOP3y ago
hmm, I don't get it to work:
if (interaction.options.getUser('user').id == null) { //code }
if (interaction.options.getUser('user').id == null) { //code }
get me
TypeError: Cannot read properties of null (reading 'id')
TypeError: Cannot read properties of null (reading 'id')
I have to remove the .id yeah... makes sense, sry Thanks anyways 🙂
MrMythical
MrMythical3y ago
👍
Want results from more Discord servers?
Add your server