!v alias for !volume that does NOT set to 0 when query is null

Saw this in a previous post

`!addcom !v -a=!volume $(query)`

But if you type !v on its own it will set your volume to 0.

Would prefer that a null result tells you the current volume. Tinkered around with the following code but it wasn’t sticking:

`$(eval x=$(query);for('$(query)' === 'null' ? ''))`

Hey @evalhelpquestion!

When empty, $(query) doesn’t give you null, but an empty string. You can test that by adding the following command and calling it with no argument:

!addcom !test This is a $(query) test

Nightbot won’t answer with “This is a null test,” but with “This is a test” because $(query) is empty.

However, $(1) gives you null when empty.

With all that said, your original command works just fine for what you’re looking for:

!addcom !v -a=!volume $(query)

Kd9xW6GUDE

1 Like

Excellent, I had been tweaking the command that had previously used $(1)

Everything mentioned is true and perfect, thank you!

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