NightDev Community Forums

Make nightbot send another message if condition = true?

Im trying to set up an eval so if true then nightbot posts in chat !addpoints $(user).

$(eval if(1>2){
var gainpts = $(urlfetch https://vxrl.xyz/smm/!addpoints%20%24(user)%20+12?i=5000&d=0);
gainpts;
}else{
var losepts = $(urlfetch https://vxrl.xyz/smm/!addpoints%20%24(user)%20-12?i=5000&d=0);
losepts;
})

Cant seem to get the url fetch to make nightbot run its command?

Hey @breebreebran!

It seems like you overcomplicate things here, first of all you don’t need the $(urlfetch), and your if will always evaluate to false, because 1 will always be smaller than 2.
I assume you want people to have a 50/50 chance to respectively earn or lose 12 points. Here’s a simple solution:

$(eval p=[`-`,`+`]; `!addpoints $(user) ${p[Math.floor(Math.random()*p.length)]}12`)
1 Like

Well im trying to get nightbot send it as two messages so it can announce it first and then do the command.

var wager = $(1)

Message 1: $(user) bet wager points and lost the bet!

Message2: !addpoints $(user) wager

It looks ugly if its all in one message.

Nightbot: !addpoints BreeBreeBRAN 5 — :palm_tree::moneybag::slot_machine: |dakyngTekila|dakyngTekila|dakyngTekila| :slot_machine::moneybag::palm_tree: — BreeBreeBRAN has won 5 tekilas!!!

I’d rather get it to be

Message1:

Nightbot: :palm_tree::moneybag::slot_machine: |dakyngTekila|dakyngTekila|dakyngTekila| :slot_machine::moneybag::palm_tree: — BreeBreeBRAN has won 5 tekilas!!!

Message2:

Nightbot: !givepoints $(user) wager

Ah, I see, that’s different then. It’d have been better if you’d have given me the full picture right at the start, this way we would have solved this much faster.

This isn’t possible to do what you’re looking for with a multiple message API, as it won’t “remember” who the $(user) is on the second message, sorry.

1 Like

Are you sure you couldn’t do this? I’m pretty sure it does retain info like $(1) I know from past experience. Though I’ve never tested the user variable I would assume it to work similar. I’ll test it later tonight when I have time.

1 Like