/**
 * @file sendSpoiler command
 * @author Alexandre Hamel (a.k.a hamelatoire)
 * @license GPL-3.0
 */

/**
 * This function sends an encrypted message to an channel.
 * The message is usually a spoiler.
 * @param message
 * @param Bastion
 */
function sendSpoiler(message, Bastion) {
  const indexOfFirstSpace = message.content.indexOf(' ');
  const indexOfSecondSpace = message.content.indexOf(' ', indexOfFirstSpace + 1);
  const channelId = message.content.substring(indexOfFirstSpace, indexOfSecondSpace).trim();
  const text = message.content.substring(indexOfSecondSpace).trimLeft();
  message.client.channels.get(channelId).send({
    embed: {
      color: message.client.colors.BLUE,
      title: `This message from ${message.author.username} contains spoilers, so I encrypted it`,
      description: 'To decrypt the message, use the showSpoiler command followed by the spoiler and I\'ll DM you the decrypted text.',
      fields: [
        {
          name: 'Here is the encrypted text',
          value: Bastion.methods.rot13(text.trimLeft())
        }
      ]
    }
  }).catch(e => {
    message.client.log.error(e);
  });
}

exports.exec = (Bastion, message, args) => {
  if (args.length < 2) {
    /**
     * The command was ran with invalid parameters.
     * @fires commandUsage
     */
    return Bastion.emit('commandUsage', message, this.help);
  }

  sendSpoiler(message, Bastion).catch(e => {
    Bastion.log.error(e);
  });
};

exports.config = {
  aliases: [],
  enabled: true
};

exports.help = {
  name: 'sendSpoiler',
  description: 'Sends the message that you had sent, rot13 encoded.',
  botPermission: '',
  userTextPermission: '',
  userVoicePermission: '',
  usage: 'sendSpoiler <channelId> <text>',
  example: [ 'sendSpoiler 99999999999999999 insert spoiler here' ]
};

@@ -1558,58 +1558,205 @@
 n: '
-Sends the message that you had sent, rot13 encoded
+If you want to send a spoiler, not everyone wants to read it. So, it%5C's better to use this command to send it. People who want to read the spoilers can then use the %60showSpoiler%60 command to read it
 .',%0A
@@ -1856,24 +1856,33 @@
 er %3C
-channelId%3E %3Ctext
+CHANNEL_ID%3E %3CSPOILER_TEXT
 %3E',%0A
@@ -1929,27 +1929,42 @@
 999 
-insert spoiler here
+You know, Thanos was killed by...?
 ' %5D%0A

update usage & example of sendSpoiler command