• 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/removeDiscordBotConfig.command.ts
1
import { InvalidState, logger, type Command } from '@hicommonwealth/core';
2
import * as schemas from '@hicommonwealth/schemas';
3
import { models } from '../../database';
4
import { authRoles } from '../../middleware';
5
import { getDiscordClient } from '../../utils';
6

UNCOV
7
const log = logger(import.meta);
×
8

UNCOV
9
export const Errors = {
×
10
  ConfigNotFound: 'Config not found.',
11
};
12

13
export function RemoveDiscordBotConfig(): Command<
14
  typeof schemas.RemoveDiscordBotConfig
15
> {
16
  return {
×
17
    ...schemas.RemoveDiscordBotConfig,
18
    auth: [authRoles('admin')],
19
    body: async ({ payload }) => {
20
      const config = await models.DiscordBotConfig.findOne({
×
21
        where: {
22
          community_id: payload.community_id,
23
        },
24
      });
25
      if (!config) throw new InvalidState(Errors.ConfigNotFound);
×
26

27
      if (config.guild_id && config.guild_id !== '') {
×
28
        const client = await getDiscordClient();
×
29
        const guild = client.guilds.cache.get(config.guild_id);
×
30
        if (guild) {
×
31
          await guild.leave();
×
32
          log.trace(`Left Discord server: ${config.guild_id}`);
×
33
        } else {
34
          log.trace(`Could not find a server with ID: ${config.guild_id}`);
×
35
        }
36
      }
37

38
      await models.sequelize.transaction(async (transaction) => {
×
39
        await models.Community.update(
×
40
          {
41
            discord_config_id: null,
42
            discord_bot_webhooks_enabled: false,
43
          },
44
          {
45
            where: {
46
              id: payload.community_id,
47
            },
48
            transaction,
49
          },
50
        );
51
        await models.DiscordBotConfig.destroy({
×
52
          where: {
53
            community_id: payload.community_id,
54
          },
55
          transaction,
56
        });
57
        await models.Topic.update(
×
58
          { channel_id: null },
59
          {
60
            where: {
61
              community_id: payload.community_id,
62
            },
63
            transaction,
64
          },
65
        );
66
      });
67

68
      return { message: 'Successfully disconnected Discord' };
×
69
    },
70
  };
71
}
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