dimanche 25 octobre 2020

How would I add a 'then' to an if statement?

Working on revising my command handler for my Discord bot.

The current way the handler works, because we use serverbyserver prefixes, so we have to check each time, and we put them into an array.

If the array doesn't have the guild's prefix, it doesn't execute (so it takes two commands to execute if the bot restarted)

The code to get/cache prefixes is:

if (checkPrefix === undefined){
   bee.get.getGuildData(msg.guildID).then((data) => {
      if (data === null) return bot.createMessage(msg.channel.id,'<:red:729470177376468993> There is no data for this guild. **Contact Support**.')
   CachePrefix.push({ID: msg.guildID.toString(), prefix: data.guildPrefix});
   prefix = data.guildPrefix
})
}

I'd rather not add another command handler to that part as it's extremely long. Is there a way to do some type of 'then'? to it?

Aucun commentaire:

Enregistrer un commentaire