'use strict';

const Command = require('../../Command.js');

class AllowPrivateRoom extends Command {
  constructor(bot) {
    super(bot, 'settings.allowprivateroom', 'allow private room', 'Set whether or not to allow the bot to create private rooms.');
    this.usages = [
      { description: 'Change if the bot is allowed to create private channels', parameters: ['private rooms enabled'] },
    ];
    this.regex = new RegExp('^allow\\s?private\\s?rooms?\\s?(.+)?$', 'i');
    this.requiresAuth = true;
    this.allowDM = false;
  }

  /**
   * Run the command
   * @param {Message} message Message with a command to handle, reply to,
   *                          or perform an action based on parameters.
   * @returns {string} success status
   */
  async run(message) {
    let enable = message.strippedContent.match(this.regex)[1];
    if (!enable) {
      const embed = {
        title: 'Usage',
        type: 'rich',
        color: 0x0000ff,
        fields: [
          {
            name: `${this.bot.prefix}${this.call} <yes|no>`,
            value: '_ _',
          },
        ],
      };
      this.messageManager.embed(message, embed, true, true);
      return this.messageManager.statuses.FAILURE;
    }
    enable = enable.trim();
    let enableResponse = false;
    if (enable === 'enable' || enable === 'yes' || enable === '1'
          || enable === 'true' || enable === 'on' || enable === 1) {
      enableResponse = true;
    }
    await this.bot.settings.setGuildSetting(message.guild, 'createPrivateChannel', enableResponse);
    this.messageManager.notifySettingsChange(message, true, true);
    return this.messageManager.statuses.SUCCESS;
  }
}

module.exports = AllowPrivateRoom;

@@ -460,10 +460,14 @@
 %5Cs?(
-.+
+on%7Coff
 )?$'
@@ -1035,14 +1035,14 @@
 l%7D %3C
-yes%7Cno
+on%7Coff
 %3E%60,%0A
@@ -1301,120 +1301,13 @@
 === 
-'enable' %7C%7C enable === 'yes' %7C%7C enable === '1'%0A          %7C%7C enable === 'true' %7C%7C enable === 'on' %7C%7C enable === 1
+ 'on'
 ) %7B%0A

fix room creation options