From e6e60e12781313b44dfd03fe3e65e9f6aaf0e641 Mon Sep 17 00:00:00 2001 From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com> Date: Tue, 5 Dec 2023 11:29:17 +0330 Subject: [PATCH 1/2] 1 --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 9de709e9..cc078bf0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -51,7 +51,6 @@ const fetchMethod = async (msg: any) => { logger.info({ saga: saga.data }, 'the saga info'); const platformId = saga.data['platformId']; const platform = await platformService.getPlatform({ _id: platformId }); - console.log(platform) if (platform) { const isPlatformCreated = saga.data['created']; From 5d7e2025eebc4463b275f785a16d6066e6989570 Mon Sep 17 00:00:00 2001 From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com> Date: Tue, 5 Dec 2023 17:42:26 +0330 Subject: [PATCH 2/2] [FIXBUG]: fix bug related to fetch members --- src/events/channel/channelDelete.ts | 1 - src/events/client/ready.ts | 3 --- src/events/user/userUpdate.ts | 3 --- src/functions/cronJon.ts | 1 - src/functions/fetchChannels.ts | 1 - src/functions/fetchMembers.ts | 1 - src/functions/fetchRoles.ts | 1 - src/index.ts | 25 +++++++++++++++---------- 8 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/events/channel/channelDelete.ts b/src/events/channel/channelDelete.ts index 5db0749a..31b5eb55 100644 --- a/src/events/channel/channelDelete.ts +++ b/src/events/channel/channelDelete.ts @@ -3,7 +3,6 @@ import { channelService, platformService } from '../../database/services'; import { DatabaseManager } from '@togethercrew.dev/db'; import parentLogger from '../../config/logger'; -console.log('FLAG') const logger = parentLogger.child({ event: 'ChannelDelete' }); export default { diff --git a/src/events/client/ready.ts b/src/events/client/ready.ts index c953ba14..1bdd38b5 100644 --- a/src/events/client/ready.ts +++ b/src/events/client/ready.ts @@ -6,9 +6,6 @@ import fetchRoles from '../../functions/fetchRoles'; import { DatabaseManager } from '@togethercrew.dev/db'; import parentLogger from '../../config/logger'; -console.log('FLAG') - - const logger = parentLogger.child({ event: 'ClientReady' }); export default { diff --git a/src/events/user/userUpdate.ts b/src/events/user/userUpdate.ts index 626a1b67..b92b003c 100644 --- a/src/events/user/userUpdate.ts +++ b/src/events/user/userUpdate.ts @@ -3,9 +3,6 @@ import { guildMemberService, platformService } from '../../database/services'; import { DatabaseManager } from '@togethercrew.dev/db'; import parentLogger from '../../config/logger'; -console.log('FLAG') - - const logger = parentLogger.child({ event: 'UserUpdate' }); export default { name: Events.UserUpdate, diff --git a/src/functions/cronJon.ts b/src/functions/cronJon.ts index bc8438dc..e9cda21f 100644 --- a/src/functions/cronJon.ts +++ b/src/functions/cronJon.ts @@ -5,7 +5,6 @@ import { ChoreographyDict, MBConnection, Status } from '@togethercrew.dev/tc-mes import guildExtraction from './guildExtraction'; import parentLogger from '../config/logger'; import { DatabaseManager } from '@togethercrew.dev/db'; -console.log('FLAG') const logger = parentLogger.child({ event: 'CronJob' }); diff --git a/src/functions/fetchChannels.ts b/src/functions/fetchChannels.ts index 55600adc..dc08145c 100644 --- a/src/functions/fetchChannels.ts +++ b/src/functions/fetchChannels.ts @@ -3,7 +3,6 @@ import { Connection, HydratedDocument } from 'mongoose'; import { IPlatform, IChannel } from '@togethercrew.dev/db'; import { channelService, platformService } from '../database/services'; import parentLogger from '../config/logger'; -console.log('FLAG') const logger = parentLogger.child({ module: 'FetchChannels' }); diff --git a/src/functions/fetchMembers.ts b/src/functions/fetchMembers.ts index dc01d50d..8ef2d943 100644 --- a/src/functions/fetchMembers.ts +++ b/src/functions/fetchMembers.ts @@ -5,7 +5,6 @@ import { IGuildMember, } from '@togethercrew.dev/db'; import { guildMemberService, platformService } from '../database/services'; import parentLogger from '../config/logger'; -console.log('FLAG') const logger = parentLogger.child({ module: 'FetchMembers' }); diff --git a/src/functions/fetchRoles.ts b/src/functions/fetchRoles.ts index 38dcedc1..137259b7 100644 --- a/src/functions/fetchRoles.ts +++ b/src/functions/fetchRoles.ts @@ -4,7 +4,6 @@ import { IPlatform, IRole } from '@togethercrew.dev/db'; import { roleService, platformService } from '../database/services'; import parentLogger from '../config/logger'; -console.log('FLAG') const logger = parentLogger.child({ module: 'FetchRoles' }); diff --git a/src/index.ts b/src/index.ts index cc078bf0..8e358ecc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -159,21 +159,26 @@ async function app() { }); RabbitMQ.onEvent(Event.DISCORD_BOT.FETCH_MEMBERS, async msg => { - logger.info({ msg, event: Event.DISCORD_BOT.FETCH_MEMBERS }, 'is running'); - if (!msg) return; + try { + logger.info({ msg, event: Event.DISCORD_BOT.FETCH_MEMBERS }, 'is running'); + if (!msg) return; - const { content } = msg; - const saga = await MBConnection.models.Saga.findOne({ sagaId: content.uuid }); + const { content } = msg; + const saga = await MBConnection.models.Saga.findOne({ sagaId: content.uuid }); - const platformId = saga.data['platformId']; + const platformId = saga.data['platformId']; - const platform = await platformService.getPlatform({ _id: platformId }); + const platform = await platformService.getPlatform({ _id: platformId }); - if (platform) { - const fn = fetchInitialData.bind({}, platform.metadata?.id); - await saga.next(fn); + if (platform) { + const fn = fetchInitialData.bind({}, platform); + await saga.next(fn); + } + logger.info({ msg, event: Event.DISCORD_BOT.FETCH_MEMBERS }, 'is done'); + } catch (error) { + logger.error({ msg, event: Event.DISCORD_BOT.FETCH_MEMBERS, error }, 'is failed'); } - logger.info({ msg, event: Event.DISCORD_BOT.FETCH_MEMBERS }, 'is done'); + }); // *****************************BULLMQ