Skip to content

Commit

Permalink
Some more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Aug 8, 2023
1 parent 71d7a1f commit e36d267
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/moderation/moderation-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,22 @@ export abstract class ModerationComponent extends BotComponent {
}

override async on_ready() {
// TODO: Implement catch-up / ensuring moderations are in place
const moderations = await this.wheatley.database.moderations.find({ type: this.type, active: true }).toArray();
this.sleep_list.bulk_insert(
moderations
.filter(entry => entry.duration !== null)
.map(entry => [entry.issued_at + unwrap(entry.duration), entry]),
);
// Ensure moderations are in place
for (const moderation of moderations) {
try {
if (!(await this.is_moderation_applied(moderation))) {
await this.add_moderation(moderation);
}
} catch (e) {
critical_error(e);
}
}
}

abstract add_moderation(entry: mongo.WithId<moderation_entry>): Promise<void>;
Expand Down
2 changes: 2 additions & 0 deletions src/components/moderation/mute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ export default class Mute extends ModerationComponent {
}

async add_moderation(entry: mongo.WithId<moderation_entry>) {
M.info(`Applying mute to ${entry.user_name}`);
const member = await this.wheatley.TCCPP.members.fetch(entry.user);
await member.roles.add(this.wheatley.muted_role);
}

async remove_moderation(entry: mongo.WithId<moderation_entry>) {
M.info(`Removing mute from ${entry.user_name}`);
const member = await this.wheatley.TCCPP.members.fetch(entry.user);
await member.roles.remove(this.wheatley.muted_role);
this.sleep_list.remove(entry._id);
Expand Down

0 comments on commit e36d267

Please sign in to comment.