Skip to content

Commit

Permalink
feat: add message moderation rule setup option [1/2]
Browse files Browse the repository at this point in the history
Signed-off-by: Ar Rakin <rakinar2@onesoftnet.eu.org>
  • Loading branch information
virtual-designer committed Oct 20, 2024
1 parent 1554a42 commit ee6817e
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions src/main/typescript/services/GuildSetupService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ enum SetupOption {
Prefix = "prefix",
Logging = "logging",
AIBasedAutoMod = "ai_automod",
SpamProtection = "spam_protection"
SpamProtection = "spam_protection",
ModerationRules = "moderation_rules"

Check warning on line 41 in src/main/typescript/services/GuildSetupService.ts

View check run for this annotation

Codecov / codecov/patch

src/main/typescript/services/GuildSetupService.ts#L39-L41

Added lines #L39 - L41 were not covered by tests
}

type SetupState = {
Expand All @@ -53,7 +54,8 @@ class GuildSetupService extends Service implements HasEventListeners {
[SetupOption.Prefix]: "handlePrefixSetup",
[SetupOption.Logging]: "handleLoggingSetup",
[SetupOption.AIBasedAutoMod]: "handleAIAutoModSetup",
[SetupOption.SpamProtection]: "handleSpamProtectionSetup"
[SetupOption.SpamProtection]: "handleSpamProtectionSetup",
[SetupOption.ModerationRules]: "handleModerationRulesSetup"

Check warning on line 58 in src/main/typescript/services/GuildSetupService.ts

View check run for this annotation

Codecov / codecov/patch

src/main/typescript/services/GuildSetupService.ts#L56-L58

Added lines #L56 - L58 were not covered by tests
};
private readonly inactivityTimeout: number = 120_000;
private readonly setupState: Map<`${string}::${string}::${string}`, SetupState> = new Map();
Expand Down Expand Up @@ -152,6 +154,12 @@ class GuildSetupService extends Service implements HasEventListeners {
value: SetupOption.SpamProtection,
emoji: "🛡️",
description: "Configure AI-powered automatic moderation for this server."
},
{
label: "Moderation Rules",
value: SetupOption.ModerationRules,
emoji: "🛠️",
description: "Configure message moderation rules for this server."

Check warning on line 162 in src/main/typescript/services/GuildSetupService.ts

View check run for this annotation

Codecov / codecov/patch

src/main/typescript/services/GuildSetupService.ts#L151-L162

Added lines #L151 - L162 were not covered by tests
}
])
.setMinValues(1)
Expand Down Expand Up @@ -1184,6 +1192,38 @@ class GuildSetupService extends Service implements HasEventListeners {
);
}

Check warning on line 1193 in src/main/typescript/services/GuildSetupService.ts

View check run for this annotation

Codecov / codecov/patch

src/main/typescript/services/GuildSetupService.ts#L1180-L1193

Added lines #L1180 - L1193 were not covered by tests

public async handleModerationRulesSetup(
guildId: string,
id: string,
messageId: string,
interaction: StringSelectMenuInteraction
) {
await this.defer(interaction);
this.resetState(guildId, id, messageId);

Check warning on line 1202 in src/main/typescript/services/GuildSetupService.ts

View check run for this annotation

Codecov / codecov/patch

src/main/typescript/services/GuildSetupService.ts#L1195-L1202

Added lines #L1195 - L1202 were not covered by tests

// TODO

await this.pushState(guildId, id, messageId, {
embeds: [
this.embed(
["Message Moderation Rules"],
"Please configure the following options.",
{
color: Colors.Primary
}
)
],
components: [
this.selectMenu(guildId, true),
this.buttonRow(guildId, id, messageId, {
back: true,
cancel: true,
finish: false
})
]
});
}

Check warning on line 1225 in src/main/typescript/services/GuildSetupService.ts

View check run for this annotation

Codecov / codecov/patch

src/main/typescript/services/GuildSetupService.ts#L1206-L1225

Added lines #L1206 - L1225 were not covered by tests

public async handleSpamProtectionSetup(
guildId: string,
id: string,
Expand Down

0 comments on commit ee6817e

Please sign in to comment.