Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Clawkikker

discord bot if statement detect if var = yes then sends embed

Recommended Posts

Posted · Original PosterOP

 

Here is the relevant code:

var Started = "no";

// other stuff

// HERE IS WHERE THE CODE IS
client.on('ready', () => {
    var channel = client.channels.find(channel => channel.id === '740342329973538858');
    console.log("we in bois");
    setInterval(() => {
        channel.send({
            embed: {
                meesage
            }
        });
    }, 10000);
});


// other stuff

if (msg.content === "start") {
    var Started = 'yes';
    console.log = 'no';
}
    
// another one of the above for no

I cant figure out how to make an if statement to always check whether or not started is yes or no. I need to start when it is yes and stop when it is no (the code I'm talking about is the HERE IS WHERE THE CODE IS)

Link to post
Share on other sites

I'm not entirely sure what you're trying to achieve here.  Do you want to send a message every 10 seconds if it is started or not?

 

Also, there are a few problems with this code.  It seems like the 'Started' variable would be much better suited to the boolean type.  Despite the fact you've used it correctly on a previous line,   console.log = 'no';    will effectively delete the console.log() method.

 

 

Link to post
Share on other sites
Posted · Original PosterOP
Just now, Souffle said:

I'm not entirely sure what you're trying to achieve here.  Do you want to send a message every 10 seconds if it is started or not?

 

Also, there are a few problems with this code.  It seems like the 'Started' variable would be much better suited to the boolean type.  Despite the fact you've used it correctly on a previous line,   console.log = 'no';    will effectively delete the console.log() method.

 

 

ah ok i figured it out i removed the var for var started donw on the bottom  and added the if (started === "yes"){  before channel.send

Link to post
Share on other sites
Posted · Original PosterOP

Also anyone know in a variable how to detect in a variable like if i want to detect if a var is anywhere from 50-59, can i just detect 5_ and aslong as the numbe is 50 something then it will detect

Link to post
Share on other sites
31 minutes ago, Clawkikker said:

Also anyone know in a variable how to detect in a variable like if i want to detect if a var is anywhere from 50-59, can i just detect 5_ and aslong as the numbe is 50 something then it will detect

if (x >= 50 && x <= 59) {
  // do something
}
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×