@@ -530,13 +530,13 @@ export default {
530530 } ) ;
531531 } ,
532532 async makeRequest ( {
533- method = "" , throwRateLimitError = false , asBot = false , as_user, ...args
533+ method = "" , throwRateLimitError = false , asBot, as_user, ...args
534534 } = { } ) {
535535 const botTokenAvailable = Boolean ( this . $auth . bot_token ) ;
536536 // Passing as_user as false with a v2 user token lacking the deprecated
537- // `chat:write:bot` scope, results in an error. So if as_user is false and
538- // there's a bot token available, we should use the bot token and omit
539- // as_user. Otherwise, use the user token and pass as_user through.
537+ // `chat:write:bot` scope results in an error. If as_user is false and a
538+ // bot token is available, use the bot token and omit as_user. Otherwise,
539+ // pass as_user through.
540540 if ( as_user === false && botTokenAvailable ) {
541541 asBot = true ;
542542 } else {
@@ -556,19 +556,13 @@ export default {
556556 if ( [
557557 "not_in_channel" ,
558558 "channel_not_found" ,
559- ] . includes ( error ?. data ?. error ) && asBot ) {
560- // If method starts with chat, include the part about "As User"
561- // Otherwise, just say "Ensure the bot is a member of the channel"
562- if ( method . startsWith ( "chat." ) ) {
563- throw new ConfigurationError ( `${ error }
564- Ensure the bot is a member of the channel, or set the **Send as User** option to true to act on behalf of the authenticated user.
565- ` ) ;
566- }
567- throw new ConfigurationError ( `${ error }
568- Ensure the bot is a member of the channel.
569- ` ) ;
559+ ] . some ( ( errorType ) => error . includes ( errorType ) ) && asBot ) {
560+ const followUp = method . startsWith ( "chat." )
561+ ? "Ensure the bot is a member of the channel, or set the **Send as User** option to true to act on behalf of the authenticated user."
562+ : "Ensure the bot is a member of the channel." ;
563+ throw new ConfigurationError ( `${ error } \n${ followUp } ` ) ;
570564 }
571- throw ` ${ error } ` ;
565+ throw error ;
572566 }
573567
574568 if ( ! response . ok ) {
@@ -594,7 +588,7 @@ export default {
594588 throw error ;
595589 }
596590 }
597- bail ( error ) ;
591+ bail ( ` ${ error } ` ) ;
598592 }
599593 } , retryOpts ) ;
600594 } ,
@@ -699,7 +693,7 @@ export default {
699693 if ( ! [
700694 "method_not_supported_for_channel_type" ,
701695 "already_in_channel" ,
702- ] . some ( ( msg ) => ( error . data ?. error || error . message || error ) ?. includes ( msg ) ) ) {
696+ ] . some ( ( errorType ) => error . includes ( errorType ) ) ) {
703697 throw error ;
704698 }
705699 }
0 commit comments