Skip to content

Commit

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

[DEBUG]
  • Loading branch information
Behzad-rabiei authored Dec 6, 2023
2 parents b7b2908 + db29ed0 commit a34ce83
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/functions/fetchChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default async function fetchGuildChannels(connection: Connection, client:
) as Array<TextChannel | VoiceChannel>;
pushChannelsToArray(channelsToStore, textAndVoiceChannels);
logger.info({ channels: channelsToStore })

await channelService.createChannels(connection, channelsToStore); // assuming a 'channelService'
} catch (error) {
logger.error({ guild_id: platform.metadata?.id, error }, 'Failed to fetch channels');
Expand Down
2 changes: 0 additions & 2 deletions src/functions/fetchMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export default async function fetchGuildMembers(connection: Connection, client:
const membersToStore: IGuildMember[] = [];
const fetchMembers = await guild.members.fetch();
pushMembersToArray(membersToStore, [...fetchMembers.values()]);
logger.info({ members: membersToStore })

await guildMemberService.createGuildMembers(connection, membersToStore);
} catch (error) {
logger.error({ guild_id: platform.metadata?.id, error }, 'Failed to fetch guild members');
Expand Down
2 changes: 0 additions & 2 deletions src/functions/fetchRoles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export default async function fetchGuildRoles(connection: Connection, client: Cl
const guild = await client.guilds.fetch(platform.metadata?.id);
const rolesToStore: IRole[] = [];
pushRolesToArray(rolesToStore, [...guild.roles.cache.values()]);
logger.info({ roles: rolesToStore })

await roleService.createRoles(connection, rolesToStore);
} catch (error) {
logger.error({ guild_id: platform.metadata?.id, error }, 'Failed to fetch roles');
Expand Down
7 changes: 2 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ const fetchMethod = async (msg: any) => {
const isPlatformCreated = saga.data['created'];
const connection = DatabaseManager.getInstance().getTenantDb(platform.metadata?.id);
if (isPlatformCreated) {
await fetchChannels(connection, client, platform);
await fetchMembers(connection, client, platform);
await fetchRoles(connection, client, platform);
await fetchChannels(connection, client, platform);
} else {
await guildExtraction(connection, client, platform);
}
Expand Down Expand Up @@ -104,13 +104,12 @@ const notifyUserAboutAnalysisFinish = async (
const fetchInitialData = async (platform: HydratedDocument<IPlatform>) => {
try {
const connection = DatabaseManager.getInstance().getTenantDb(platform.metadata?.id);
await fetchRoles(connection, client, platform);
await fetchChannels(connection, client, platform);
await fetchRoles(connection, client, platform);
await fetchMembers(connection, client, platform);
} catch (error) {
logger.error({ error }, 'fetchInitialData is failed');
}

};

// APP
Expand Down Expand Up @@ -184,9 +183,7 @@ async function app() {

const platform = await platformService.getPlatform({ _id: platformId });

logger.info({ msg, event: Event.DISCORD_BOT.FETCH_MEMBERS, platform, platformId })
if (platform) {
logger.info({ event: "FETCHING Initial DATA" })
const fn = fetchInitialData.bind({}, platform);
await saga.next(fn);
}
Expand Down

0 comments on commit a34ce83

Please sign in to comment.