Skip to content

Commit

Permalink
Fix for user group ID mention format
Browse files Browse the repository at this point in the history
  • Loading branch information
BenTomsett committed Feb 12, 2024
1 parent b8a33ba commit 7873787
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/commands/changeMention.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Middleware, SlackCommandMiddlewareArgs } from '@slack/bolt/dist/types';
import { invalidChangeMentionParameters, invalidLunchParameters } from '../responses/commandResponses';
import { invalidChangeMentionParameters } from '../responses/commandResponses';
import { channels } from '../db';

const changeMentionCommandCallback: Middleware<SlackCommandMiddlewareArgs> = async ({
Expand All @@ -9,17 +9,18 @@ const changeMentionCommandCallback: Middleware<SlackCommandMiddlewareArgs> = asy
}) => {
await ack();

console.log(`⬇️ ${command.user_id} (${command.user_name}) invoked /change_mention`);
console.log(`⬇️ ${command.user_id} (${command.user_name}) invoked /change_mention (with text: ${command.text})`);

// Mention types (all valid for this command):
// special mentions (e.g. @here) -> <!here>
// user mentions -> <@U02S5G1SN8M|benji>
// bot/app mentions -> <@U06JQ5XF89F|lunchbot2>
// channel mentions -> <#C03PN47NT09|>
// user group mentions -> <!subteam^S06JQ5XFA|frontend>

const mentionRegex = /<(([@!#])[A-Z0-9]+)(\|[a-z0-9]*)?>/i;
const mentionRegex = /<(([@!#]|(!subteam\^))[A-Z0-9]+)(\|[a-z0-9]*)?>/i;

if (command.text == '') {
if (command.text === '') {
return invalidChangeMentionParameters(respond);
}

Expand All @@ -39,8 +40,6 @@ const changeMentionCommandCallback: Middleware<SlackCommandMiddlewareArgs> = asy
teamId: command.team_id,
};

console.log({ ...channelInfo, mention });

await channels.updateOne(channelInfo, { $set: { ...channelInfo, mention } }, { upsert: true });

await respond({
Expand Down

0 comments on commit 7873787

Please sign in to comment.