• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hicommonwealth / commonwealth / 22329524614

23 Feb 2026 11:33PM UTC coverage: 38.204% (+0.03%) from 38.173%
22329524614

Pull #13194

github

web-flow
Merge 19ef2c5a5 into 6658c85df
Pull Request #13194: AI Completion Fixes

2110 of 6026 branches covered (35.01%)

Branch coverage included in aggregate %.

9 of 80 new or added lines in 3 files covered. (11.25%)

30 existing lines in 14 files now uncovered.

3752 of 9318 relevant lines covered (40.27%)

52.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/libs/model/src/aggregates/discordBot/createDiscordBotConfig.command.ts
1
import { type Command, InvalidState } from '@hicommonwealth/core';
2
import * as schemas from '@hicommonwealth/schemas';
3
import { canIntegrateDiscord, CommunityTierMap } from '@hicommonwealth/shared';
4
import { models } from '../../database';
5
import { authRoles } from '../../middleware';
6

UNCOV
7
const TOKEN_EXPIRATION_MINUTES = 5;
×
8

9
export function CreateDiscordBotConfig(): Command<
10
  typeof schemas.CreateDiscordBotConfig
11
> {
12
  return {
×
13
    ...schemas.CreateDiscordBotConfig,
14
    auth: [authRoles('admin')],
15
    secure: true,
16
    body: async ({ payload }) => {
17
      const { community_id, verification_token } = payload;
×
18
      const token_expiration = new Date(
×
19
        +new Date() + TOKEN_EXPIRATION_MINUTES * 60 * 1000,
20
      );
21

22
      const community = await models.Community.findOne({
×
23
        attributes: ['tier'],
24
        where: {
25
          id: community_id,
26
        },
27
      });
28
      if (!community) {
×
29
        throw new InvalidState('Community not found');
×
30
      }
31

32
      if (!canIntegrateDiscord(community)) {
×
33
        throw new InvalidState(
×
34
          `Community tier must be at least ${CommunityTierMap.ManuallyVerified}`,
35
        );
36
      }
37

38
      const existing = await models.DiscordBotConfig.findOne({
×
39
        where: {
40
          community_id,
41
        },
42
      });
43

44
      if (existing) {
×
45
        const existingConfig = await existing.update(
×
46
          {
47
            verification_token,
48
            token_expiration,
49
          },
50
          {
51
            where: {
52
              community_id,
53
            },
54
          },
55
        );
56

57
        await models.Community.update(
×
58
          { discord_config_id: existingConfig.id },
59
          { where: { id: community_id } },
60
        );
61

62
        return { message: 'Updated an existing discord bot config' };
×
63
      }
64

65
      await models.DiscordBotConfig.create({
×
66
        community_id,
67
        verification_token,
68
        token_expiration,
69
      });
70

71
      return { message: 'Created a new discord bot config' };
×
72
    },
73
  };
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc