{"size": 1308, "ext": "js", "max_stars_repo_path": "src/commands/updatesettings/addwc.js", "max_stars_repo_name": "SenterisTeam/SentDiscordBot", "max_stars_repo_stars_event_min_datetime": "2019-10-09T16:38:34.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-14T16:19:48.000Z", "max_issues_repo_path": "src/commands/updatesettings/addwc.js", "max_issues_repo_name": "Xefise/SntrDiscordBot", "max_issues_repo_issues_event_min_datetime": "2019-12-01T22:00:57.000Z", "max_issues_repo_issues_event_max_datetime": "2019-12-01T22:00:57.000Z", "max_forks_repo_path": "src/commands/updatesettings/addwc.js", "max_forks_repo_name": "Xefise/SntrDiscordBot", "max_forks_repo_forks_event_min_datetime": "2020-06-26T18:44:15.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-26T18:44:15.000Z"}
{"max_stars_count": 4, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 50.3076923077, "max_line_length": 156, "alphanum_fraction": 0.6659021407}
const db = require("../../db.js");
const { log } = require("../../functions.js");

exports.run = (client, message, args) => {
  if (!message.member.hasPermission("ADMINISTRATOR")) return message.reply("**Error:** You are **not administrator**!");
  if (args.length == 0) return message.reply("Not enough arguments. Type !-help");

  new Promise(function (resolve) {
    db.getGuild(message.guild, resolve);
  }).then(function (guildDB) {
    let nameWC = new String();
    if (args.length > 1) nameWC = args.slice(0, args.length).join(" ");
    else nameWC = String(args[0]); // I did not test what will be if I delete String() :)
    guildDB.whiteChannels.push(nameWC);
    const whiteChannelsJSON = JSON.stringify(guildDB.whiteChannels);
    if(whiteChannelsJSON.length >= 255) return message.reply("**Error:** Too much channels! Please shorten the channel names.");

    new Promise(function (resolve) {
      db.updateGuild("whiteChannels", `'${whiteChannelsJSON}'`, message.guild, resolve);
    }).then(function (res) {
      if(res) message.reply("White channels have been changed!");
      else return message.reply("Error :(");
      log(`White channels have been changed to ${whiteChannelsJSON} by ${message.author.tag}`, message.guild, "Guild " + message.guild, message.member.tag);
    });
  });
}