Skip to content

Commit 2126d8e

Browse files
committed
don't throw error when adding app to channels fails
1 parent 3aa0773 commit 2126d8e

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

components/slack/slack.app.mjs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -673,30 +673,30 @@ export default {
673673
},
674674
async maybeAddAppToChannels(channelIds = []) {
675675
if (!this.$auth.bot_token) return;
676-
const {
677-
bot_id, user_id,
678-
} = await this.authTest({
679-
asBot: true,
680-
});
681-
if (!bot_id) {
682-
throw new Error("Could not get bot ID. Make sure the Slack app has a bot user.");
683-
}
684-
// XXX: Trying to add the app to DM or group DM channels results in the
685-
// error: method_not_supported_for_channel_type
686-
for (const channel of channelIds) {
687-
try {
688-
await this.inviteToConversation({
689-
channel,
690-
users: user_id,
691-
});
692-
} catch (error) {
693-
if (![
694-
"method_not_supported_for_channel_type",
695-
"already_in_channel",
696-
].some((errorType) => error.includes(errorType))) {
697-
throw error;
676+
try {
677+
const {
678+
bot_id, user_id,
679+
} = await this.authTest({
680+
asBot: true,
681+
});
682+
if (!bot_id) {
683+
console.log("Skipping adding Slack app to channels: bot ID unavailable.");
684+
return;
685+
}
686+
for (const channel of channelIds) {
687+
try {
688+
// Note: Trying to add the app to DM or group DM channels results in
689+
// the error: method_not_supported_for_channel_type
690+
await this.inviteToConversation({
691+
channel,
692+
users: user_id,
693+
});
694+
} catch (error) {
695+
console.log(`Unable to add Slack app to channel ${channel}: ${error}`);
698696
}
699697
}
698+
} catch (error) {
699+
console.log(`Unable to add Slack app to channels: ${error}`);
700700
}
701701
},
702702
/**

0 commit comments

Comments
 (0)