Home > Blockchain >  I need help s4dmessage.channel.send
I need help s4dmessage.channel.send

Time:08-07

I wanna add after it gives me the random integer a "%", how do I do that?

function mathRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min)   min);
}
                  
const randomInteger = `${mathRandomInt(1, 100)}%`;  
                  
s4d.client.on('messageCreate', async (s4dmessage) => {

  if ((s4dmessage.content) == '!homeless') {
       
    s4dmessage.channel.send(randomInteger);    
        
  }

i edited it , this is what i have and i get the same issue

CodePudding user response:

You can use backticks ( `` ) to access a variable in a string. In order to use the variable, you need to surround it with : ${yourVariable}

Inside your client.on("messageCreate") add this:

// added function example
function mathRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min)   min);
}

const randomInteger = `${mathRandomInt(1, 100)}%`;
s4dmessage.channel.send(randomInteger);
  • Related