8Ball command breaking when using an apostrophe as the query

Hello!
I have an !8ball command that works really well:

!editcom !8ball :8ball: $(eval var question = ['All signs point to yes...', 'Yes!', 'My sources say nope.', 'You may rely on it.', 'Concentrate and ask again...', 'Outlook not so good...', 'It is decidedly so!', 'Better not tell you.', 'Very doubtful.', 'Yes - Definitely!', 'It is certain!', 'Most likely.', 'Ask again later.', 'No!', 'Outlook good.', "Don't count on it."]; '$(querystring)'.trim() == '' ? 'Please ask a question.' : question[Math.floor(Math.random() * question.length)];) :8ball:

However when I type a question with an apostrophe ( ’ ) in it, for example “Let’s try again okay?”, the command flips out and responds with: Right-hand side of ‘instanceof’ is not an object

My question is: is there any way to fix that?

Thanks a ton in advance!

Replace '$(querystring)'.trim() with

`$(querystring)`.trim()

A grave accent is less likely to be used.

1 Like

It works! Thank you very much! Didn’t know those could be used instead of " or '… hell didn’t even know they were called Grave accents. Could say it’s because I’m natively Spanish but not sure what they are called in Spanish either >_>

Anyway, thank you!!

Good ol Javascript and its Template literals.

1 Like

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