Skip to content

Commit

Permalink
✨Smol feature being added to when guilds join
Browse files Browse the repository at this point in the history
Resolves #116
  • Loading branch information
EdgarSaldivar committed Mar 8, 2023
1 parent 10043c8 commit c6d81f7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/bot/events/update-guilds.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable, UseInterceptors } from '@nestjs/common';
import { InjectDiscordClient, On } from '@discord-nestjs/core';
import { Client, Events, Guild, OAuth2Guild } from 'discord.js';
import { Client, Events, Guild, MessagePayload, OAuth2Guild } from 'discord.js';
import { InjectRepository } from '@mikro-orm/nestjs';
import { MikroORM, NotFoundError, UseRequestContext } from '@mikro-orm/core';
import { EntityRepository } from '@mikro-orm/postgresql';
Expand All @@ -9,6 +9,7 @@ import { SchedulingService } from 'src/scheduling/scheduling.service';
import { GuildEntity } from 'src/entities/guild/guild.entity';
import { DiscordHelperService } from '../discord-helper.service';
import { TimingLogInterceptor } from '../interceptors/logging.interceptor';
import { RulesService } from '../rules.service';

@Injectable()
@UseInterceptors(TimingLogInterceptor)
Expand All @@ -19,6 +20,7 @@ export class UpdatedGuilds {
private readonly guilds: EntityRepository<GuildEntity>,
private readonly discord_helper: DiscordHelperService,
private readonly scheduling: SchedulingService,
private readonly rules: RulesService,
@InjectDiscordClient()
private readonly client: Client,
) {}
Expand Down Expand Up @@ -74,12 +76,17 @@ export class UpdatedGuilds {
});

await this.discord_helper.findOrCreateBiggestVirginRole(guild_ent);
await this.discord_helper.findOrCreateVirginityBotChannel(guild_ent);
const channel = await this.discord_helper.findOrCreateVirginityBotChannel(
guild_ent,
);

await this.guilds.flush();

await this.scheduling.scheduleResets();

const rulesBoard = await this.rules.buildRulesboardEmbed(guild_ent);
await channel.send(new MessagePayload(channel, { embeds: [rulesBoard] }));

return guild_ent;
}

Expand Down

0 comments on commit c6d81f7

Please sign in to comment.