Enhance bot functionality with AutoMod, Logging, Welcome, and Verification features

- Implemented AutoMod capabilities including spam filtering, anti-raid, and anti-nuke actions.
- Added Logging module to track moderation actions and events across the bot.
- Introduced Welcome module for customizable welcome messages and autoroles.
- Developed Verification system with captcha and role assignment features.
- Updated Prisma schema to include new models for AutoMod, Logging, Welcome, and Verification.
- Enhanced command localization for new features in both German and English.
- Improved health server to handle captcha verification requests.
- Added new environment variable for public base URL to support captcha links.
This commit is contained in:
smueller
2026-07-22 12:28:42 +02:00
parent a44f4d6641
commit 2518119257
37 changed files with 3002 additions and 108 deletions

View File

@@ -0,0 +1,56 @@
import type { PrismaClient } from '@prisma/client';
import type { WelcomeEmbed, WelcomeMessageType } from '@nexumi/shared';
import { applyWelcomePlaceholders } from '@nexumi/shared';
import type { Guild, GuildMember } from 'discord.js';
import { ensureGuild } from '../../guild.js';
export async function getWelcomeConfig(prisma: PrismaClient, guildId: string) {
await ensureGuild(prisma, guildId);
let config = await prisma.welcomeConfig.findUnique({ where: { guildId } });
if (!config) {
config = await prisma.welcomeConfig.create({ data: { guildId } });
}
return config;
}
export function buildPlaceholderVars(member: GuildMember, guild: Guild) {
return {
user: `<@${member.id}>`,
'user.name': member.displayName,
'user.tag': member.user.tag,
'user.id': member.id,
server: guild.name,
memberCount: guild.memberCount
};
}
export function renderWelcomeText(template: string, member: GuildMember, guild: Guild): string {
return applyWelcomePlaceholders(template, buildPlaceholderVars(member, guild));
}
export function parseWelcomeEmbed(raw: unknown): WelcomeEmbed | null {
if (!raw || typeof raw !== 'object') {
return null;
}
return raw as WelcomeEmbed;
}
export type WelcomePayload = {
type: WelcomeMessageType;
content?: string | null;
embed?: WelcomeEmbed | null;
imageTitle?: string | null;
imageSubtitle?: string | null;
};
export function resolveWelcomePayload(
config: Awaited<ReturnType<typeof getWelcomeConfig>>
): WelcomePayload {
return {
type: config.welcomeType as WelcomeMessageType,
content: config.welcomeContent,
embed: parseWelcomeEmbed(config.welcomeEmbed),
imageTitle: config.imageTitle,
imageSubtitle: config.imageSubtitle
};
}