dimanche 4 novembre 2018

Discord.js - message.author.id === config.admin

Hey can you help me? I am currently working on a Discord.js bot and I'm trying to write a system where only given ID's in a JSON can execute the command. I do not know how to query this in an if statement.

Here my Code:

    if (message.author.id === config.admin) {
    if (cmd === 'mode') {
      let mode = args[0];
      if (mode === 'maintenance') {
        bot.user.setActivity(config.maintenanceGame);
        config.mode = 'maintenance';
        const embed = new Discord.RichEmbed()
          .setAuthor("Gorded Media Ltd. - Maintenance", 'http://imageurl/logo.png')
          .setColor(color.red)
          .setDescription("The mode was set to `Maintenance`. All users can't use the commands in this mode.");
        message.channel.send(embed);
      }
      if (mode === 'online') {
        bot.user.setActivity(config.defaultGame);
        config.mode = 'online';
        const embed = new Discord.RichEmbed()
          .setAuthor("Gorded Media Ltd. - Maintenance", 'http://imageurl/logo.png')
          .setColor(color.lime)
          .setDescription("The mode was set to `Online`. All users can use the commands in this mode.");
        message.channel.send(embed);
      }
      console.log(`[` + date + `] ` + config.consoleprefix + ` User ${message.author.tag} set the mode to ${config.mode}`);
    }
  }
  else {
    message.channel.send(no_perms)
  }

And here the JSON:

   "admin": [
    "Discord Client ID",
    "Discord Client ID",
    "Discord Client ID"
   ]

Aucun commentaire:

Enregistrer un commentaire