Skip to content

Commit

Permalink
Merge pull request #139 from TogetherCrew/135-implement-community-cen…
Browse files Browse the repository at this point in the history
…tric-version-for-discord-bot

135 implement community centric version for discord bot
  • Loading branch information
cyri113 authored Dec 5, 2023
2 parents cf894b2 + 30be1a3 commit aa40dc3
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/events/channel/channelDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions src/events/client/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions src/events/user/userUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/functions/cronJon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });

Expand Down
1 change: 0 additions & 1 deletion src/functions/fetchChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });

Expand Down
1 change: 0 additions & 1 deletion src/functions/fetchMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });

Expand Down
1 change: 0 additions & 1 deletion src/functions/fetchRoles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });

Expand Down
26 changes: 15 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -160,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
Expand Down

0 comments on commit aa40dc3

Please sign in to comment.