Skip to content

Commit

Permalink
feat: added auto-join functionality, #205 (#375)
Browse files Browse the repository at this point in the history
* added auto-join functionality, updated manifest

* fix: ran linter

---------

Co-authored-by: rhoofard <[email protected]>
  • Loading branch information
rhoofard and rhoofard authored Jun 21, 2023
1 parent b0bff2c commit 6aa975e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions features/join.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { SlackError } = require("../service/errors");
const {
handleSlackError,
handleGenericError,
} = require("../service/messageutils");

module.exports = function (app) {
app.event("channel_created", joinPublicChannel);
};

async function joinPublicChannel({ event, client }) {
try {
client.conversations.join({ channel: event.channel.id });
} catch (e) {
if (e instanceof SlackError) {
return handleSlackError(client, event, e);
} else {
return handleGenericError(client, event, e);
}
}
}
2 changes: 2 additions & 0 deletions slack_app_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ oauth_config:
- app_mentions:read
- channels:history
- channels:read
- channels:join
- chat:write
- groups:history
- groups:read
Expand All @@ -36,6 +37,7 @@ settings:
event_subscriptions:
bot_events:
- app_mention
- channel_created
- message.channels
- message.groups
- message.im
Expand Down

0 comments on commit 6aa975e

Please sign in to comment.