Custom Randomizer $(eval) troubles

Asked Oct 21, 2020·2 replies·Last activity 5 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hi, I have currently written a custom API random Tarot Card generator, and I have used the template for the !8ball command. Here it is:

!commands add !tarot You drew $(eval const responses = [‘The Fool!’, ‘The Magician!’, ’The High Priestess!’, ‘The Empress!’, ‘The Emperor!’, ‘The Hierophant!’, ‘The Lovers!’, ’The Chariot!’, ‘Justice!’, ’Strength!’, ‘The Hermit!’, ‘Wheel of Fortune!’, ’The Hanged Man!’, ‘Death!’, ‘Temperance!’, ‘The Devil!’, ‘The Tower!’, ‘The Star!’, ‘The Moon!’, ‘The Sun!’, ‘Judgement!’, ‘The World!’]; responses[Math.floor(Math.random() * responses.length)];)

When I test the command in my chat it says "invalid or unexpected token"

Is there something wrong in the HTML that I did wrong that's causing it to glitch? Let me know if there are any solutions to this problem.

2 replies

What worked for me was replacing the ‘ or ’ that was in your command with the symbol ' which is slightly different. Try the code that I posted below.

!commands add !tarot You drew $(eval const responses = ['The Fool!', 'The Magician!', 'The High Priestess!', 'The Empress!', 'The Emperor!', 'The Hierophant!', 'The Lovers!', 'The Chariot!', 'Justice!', 'Strength!', 'The Hermit!', 'Wheel of Fortune!', 'The Hanged Man!', 'Death!', 'Temperance!', 'The Devil!', 'The Tower!', 'The Star!', 'The Moon!', 'The Sun!', 'Judgement!', 'The World!']; responses[Math.floor(Math.random() * responses.length)];)

(Edit) Thank you potatoeaterlove for guidance, in the post below, on how to properly format the text in here. Apologies for doing it wrong.

If the above code doesn’t work try this just because the command above doesn’t look like right notation either.

!commands add !tarot You drew $(eval responses=[`The Fool!`,`The Magician!`,
`The High Priestess!`,`The Empress!`,`The Emperor!`,`The Hierophant!`,
`The Lovers!`,`The Chariot!`,`Justice!`,`Strength!`,`The Hermit!`,`Wheel of Fortune!`,
`The Hanged Man!`,`Death!`,`Temperance!`,`The Devil!`,`The Tower!`,`The Star!`,
`The Moon!`,`The Sun!`,`Judgement!`,`The World!`];
responses[Math.floor(Math.random()*responses.length)])

For future reference @Lively Unicorn to not have the “ \` ” changed surrounding the text you want formatted properly put “ ``` ” on the top and bottom of the text.
Like this:

\\\`
Text here
\\\`