mercredi 26 mai 2021

Discord Bot won't run pass certain point in my if statement | Javascript

  • I can't figure out why my code doesn't run anything past the first if statement.
  • I can make it run completely if I predefine the time variable.
  • Although I'm not sure when I try to take the user input, it won't continue.
  • I don't code much in JavaScript so I'm probably missing something obvious. All help is appreciated.
if (msg.content === "$set") {
    time = msg.content.split("$set ")[1]
    if(!time)return msg.reply("how many minutes / hours will you set the alarm")
    
    // Nothing runs past here unless I predefine the time variable

    const exampleEmbed = new Discord.MessageEmbed()
    .setColor('#26aaff')
    .setTitle('Custom Alert Set')
    .setAuthor('Temp', 'https://i.imgur.com/XX6I7Hj.jpeg', 'https://imgur.com/')
    .setDescription(`Time: ${time}`)
    .setThumbnail('https://i.imgur.com/XX6I7Hj.jpeg')
    .addFields(
      { name: 'Regular field title', value: 'Some value here' },
      { name: '\u200B', value: '\u200B' },
    )
    .setTimestamp()
    .setFooter('Built by', 'https://i.imgur.com/XX6I7Hj.jpeg');

    msg.channel.send(exampleEmbed)
  }

Aucun commentaire:

Enregistrer un commentaire