Love Meter/Love Test Fix

Asked Mar 5, 2025·4 replies·Last activity 1 year 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.

Hey. So I'm getting close to having the command work for me, but for some odd reason, it mentions (or @) me twice rather than mentioning who I @member if that makes sense. Any fixes and where did I go wrong? And also, is there a way to construct this to be under 500 characters if possible?

This is the command where I left off:

$(eval const u1 = "$(user)", u2 = "$(touser)", score = Math.random()*100|0, data = $(urlfetch json https://pastebin.com/raw/BnN28qsM), r = score < 21 ? data.loveMeter["0-20"] : score < 41 ? data.loveMeter["21-40"] : score < 61 ? data.loveMeter["41-60"] : score < 81 ? data.loveMeter["61-80"] : data.loveMeter["81-100"], p = r[Math.random()*r.length|0]; u2 ? u1 + " and @" + u2 + " have a love score of " + score + "%! " + p : u1 + " needs a second user." )

Get back to me whenever. Making commands is like fun to me now lol.

4 replies

The default value of touser is the current user. so instead of u2 ? you want u1 !== u2 ?

Sorry that I'm 4 days behind on this response. I forgot that I submited this. I'll test this out tonight with a different person. My best guess is I'll need to try it with another user other than Nightbot itself maybe? The response I get back is this:

!lovetest @member

Nightbot: ImKrizza needs a second user.

If it's not entirely possible to mention and highlight both names, that's fine too.

How you implemented commands speaks more to humans than a programming language. We shouldn't need to do a random number between 0 - 100 if there are only 5 categories. We also don't use the categories in a meaningful way, so we can ignore them and merge the list from bad to good. Grab a random array index once then take the index and scale it from 0-100.

Something like the example below will accomplish the same goals while allowing for more quotes (although they need to be ordered correctly).

$(eval let u1=`$(user)`, u2=`$(touser)`, d = $(urlfetch json https://pastebin.com/raw/uzb4YxiS),r = Math.floor(Math.random() * d.length), s = Math.round((r / (d.length - 1)) * 100); u1 == u2 ? `${u1} needs a second user.` : `Love Score: ${s}, ${d[r]}`)

The above example is using an updated list from the pastebin you posted earlier: https://pastebin.com/raw/uzb4YxiS