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

hicommonwealth / commonwealth / 16226169862

11 Jul 2025 05:37PM UTC coverage: 39.752% (-0.2%) from 39.977%
16226169862

push

github

web-flow
Merge pull request #12611 from hicommonwealth/rotorsoft/12610-clean-self-imports

Clean self imports

1857 of 5042 branches covered (36.83%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

27 existing lines in 12 files now uncovered.

3269 of 7853 relevant lines covered (41.63%)

36.23 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