Posting 2 timezones command

Asked Jan 27, 2020·3 replies·Last activity 6 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.

I've been looking at this command and am wondering why it isn't working.
If anyone would kindly look at it, it would be highly appreciated.

This is a command for posting time depending on which name is input.

$(eval
var r = false;
if( '$(touser)'.replace(/@/g,"")) == 'name1')
r = '$(time America/Los_Angeles)';
else if('$(touser)'.replace(/@/g,"")) == 'Name2'||'name2')
r = '$(time Asia/Singapore)';
if (r)
'The time for ' + '$(touser)'.replace(/@/g,"")) +' is : '+ r + '.';
else 'Too bad Mod is too lazy to code the timezone for you lmao';
)

The problem I'm having is that even if the touser variable is not equal to name1 or name2 it would still post a timezone instead of writing the else statement.

Thank you for your help.

3 replies

I expect this is because your $(touser) is nested too deep and is not expanded. But I don't see why you need the $(eval) inside an $(eval) -- you can do that without.

oh didnt noticed I put too many $(eval). thanks for that. working with no sleep.
Also what do you mean its not expanded?

Sorry I havent coded anything for a decade now.

You can't nest variables too deep; if you do the ones that are, are simply ignored.