First of all, you’re using “” when JavaScript only supports ", ', `. Then, $(query) needs to be turned into text to be used, this is what produces the error.
Next, there are ways to improve your code, such as testing if there’s a number input at the beginning of the code:
$(eval a = 123; q = `$(query)`; if (q && !isNaN(q)) {q < a ? `Too low` : q > a ? `Too high` : q == a ? `Bingo!` : `Error`} else {`Please type a number`})
I also used ternary operators to replace most of the if else.
Nightbot being limited in number of characters per commands, I’m saving space by renaming the variables shorter names.