toUpperCase() usage/clarification

i want to have a simple command that repeats the user input but puts their response in all capital letters. ultimately, this is for use in a bigger command set, but i’ve got the rest figured out.

i have tried “$(query).toUpperCase()” which gives me the same thing the user types in, followed by the .toUpperCase().

i then tried “$(query.toUpperCase())” which gives me [invalid variable]

Hiya, the query variable is just a string, try:
'$(query)'.toUpperCase()

with that change, i now receive:

User: !test red blue
Nightbot: ‘red blue’.toUpperCase()

i’m guessing i’m missing some kind of classification variable at the start of the while thing, but i have no idea what it should be.

Make sure you’re using it inside the $(eval) variable to execute the javascript, like this:
!commands add !test $(eval '$(query)'.toUpperCase())

1 Like

ah, that eval thing was the issue. thank you so much! fixed!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.