feat(bots/discord): add more options for curing, fix default regex

This commit is contained in:
PalmDevs
2024-07-31 19:29:27 +07:00
parent 98ec37b5d1
commit 1a4ec1ece8
2 changed files with 4 additions and 2 deletions

View File

@@ -9,6 +9,8 @@ export type Config = {
moderation?: {
roles: string[]
cure?: {
minimumNameLength?: number
removeCharactersRegex?: RegExp
defaultName: string
}
log?: {

View File

@@ -54,9 +54,9 @@ export const cureNickname = async (member: GuildMember) => {
const name = member.displayName
let cured = decancer(name)
.toString()
.replace(/[^a-zA-Z0-9]/g, '')
.replace(new RegExp(config.moderation?.cure?.removeCharactersRegex ?? '[^a-zA-Z0-9 \\-_]', 'g'), '')
if (cured.length < 3 || !/^[a-zA-Z]/.test(cured))
if (cured.length < (config?.moderation?.cure?.minimumNameLength ?? 3))
cured =
member.user.username.length >= 3
? member.user.username