composeMessage ({
    captcha,
    from_subreddit, fromSubreddit = from_subreddit,
    captcha_iden, captchaIden = captcha_iden,
    subject,
    text,
    to
  }) {
    let parsedTo = to;
    let parsedFromSr = fromSubreddit;
    if (to instanceof snoowrap.objects.RedditUser) {
      parsedTo = to.name;
    } else if (to instanceof snoowrap.objects.Subreddit) {
      parsedTo = `/r/${to.display_name}`;
    }
    if (fromSubreddit instanceof snoowrap.objects.Subreddit) {
      parsedFromSr = fromSubreddit.display_name;
    } else if (typeof fromSubreddit === 'string') {
      parsedFromSr = fromSubreddit.replace(/^\/?r\//, ''); // Convert '/r/subreddit_name' to 'subreddit_name'
    }
    return this._post({
      uri: 'api/compose', form: {
        api_type, captcha, iden: captchaIden, from_sr: parsedFromSr, subject, text, to: parsedTo
      }
    }).tap(handleJsonErrors(this)).return({});
  }
/**
   * @summary Composes a new private message.
   * @param {object} options
   * @param {RedditUser|Subreddit|string} options.to The recipient of the message.
   * @param {string} options.subject The message subject (100 characters max)
   * @param {string} options.text The body of the message, in raw markdown text
   * @param {Subreddit|string} [options.fromSubreddit] If provided, the message is sent as a modmail from the specified
   subreddit.
   * @param {string} [options.captchaIden] A captcha identifier. This is only necessary if the authenticated account
   requires a captcha to submit posts and comments.
   * @param {string} [options.captchaResponse] The response to the captcha with the given identifier
   * @returns {Promise} A Promise that fulfills when the request is complete
   * @example
   *
   * r.composeMessage({
   *   to: 'actually_an_aardvark',
   *   subject: "Hi, how's it going?",
   *   text: 'Long time no see'
   * })
   * // (message created on reddit)
   */
@summary Composes a new private message.
@param {object} options
@param {RedditUser|Subreddit|string} options.to The recipient of the message.
@param {string} options.subject The message subject (100 characters max)
@param {string} options.text The body of the message, in raw markdown text
@param {Subreddit|string} [options.fromSubreddit] If provided, the message is sent as a modmail from the specified
subreddit.
@param {string} [options.captchaIden] A captcha identifier. This is only necessary if the authenticated account
requires a captcha to submit posts and comments.
@param {string} [options.captchaResponse] The response to the captcha with the given identifier
@returns {Promise} A Promise that fulfills when the request is complete
@example


@summary Composes a new private message . @param { object } options @param { RedditUser|Subreddit|string } options . to The recipient of the message . @param { string } options . subject The message subject ( 100 characters max ) @param { string } options . text The body of the message in raw markdown text @param { Subreddit|string } [ options . fromSubreddit ] If provided the message is sent as a modmail from the specified subreddit . @param { string } [ options . captchaIden ] A captcha identifier . This is only necessary if the authenticated account requires a captcha to submit posts and comments . @param { string } [ options . captchaResponse ] The response to the captcha with the given identifier @returns { Promise } A Promise that fulfills when the request is complete @example
composeMessage ({
    captcha,
    from_subreddit, fromSubreddit = from_subreddit,
    captcha_iden, captchaIden = captcha_iden,
    subject,
    text,
    to
  }) {
    let parsedTo = to;
    let parsedFromSr = fromSubreddit;
    if (to instanceof snoowrap.objects.RedditUser) {
      parsedTo = to.name;
    } else if (to instanceof snoowrap.objects.Subreddit) {
      parsedTo = `/r/${to.display_name}`;
    }
    if (fromSubreddit instanceof snoowrap.objects.Subreddit) {
      parsedFromSr = fromSubreddit.display_name;
    } else if (typeof fromSubreddit === 'string') {
      parsedFromSr = fromSubreddit.replace(/^\/?r\//, ''); 
    }
    return this._post({
      uri: 'api/compose', form: {
        api_type, captcha, iden: captchaIden, from_sr: parsedFromSr, subject, text, to: parsedTo
      }
    }).tap(handleJsonErrors(this)).return({});
  }
composeMessage ( { captcha , from_subreddit , fromSubreddit = from_subreddit , captcha_iden , captchaIden = captcha_iden , subject , text , to } ) { let parsedTo = to ; let parsedFromSr = fromSubreddit ; if ( to instanceof snoowrap . objects . RedditUser ) { parsedTo = to . name ; } else if ( to instanceof snoowrap . objects . Subreddit ) { parsedTo = ` ${ to . display_name } ` ; } if ( fromSubreddit instanceof snoowrap . objects . Subreddit ) { parsedFromSr = fromSubreddit . display_name ; } else if ( typeof fromSubreddit === 'string' ) { parsedFromSr = fromSubreddit . replace ( / ^\/?r\/ / , '' ) ; } return this . _post ( { uri : 'api/compose' , form : { api_type , captcha , iden : captchaIden , from_sr : parsedFromSr , subject , text , to : parsedTo } } ) . tap ( handleJsonErrors ( this ) ) . return ( { } ) ; }
@summary Composes a new private message.
@summary Composes a new private message .
// Convert '/r/subreddit_name' to 'subreddit_name'