ProfanityFilter
- community
- anti-cheat
- by limon
- Takaro main
- all
Maintain a respectful and positive gaming environment.
This module helps you automatically moderate chat and reduce profanity. It allows you to:
- Customize your list of prohibited words: Easily add, remove, or modify the list of offensive terms you want to filter.
- Choose from various punishment options: Issue warnings, impose fines (in-game currency), kick, or even ban players for using inappropriate language.
- Set up a swear jar: Encourage players to watch their language by adding a fine to the swear jar for each infraction.
- Configure warnings and reset times: Fine-tune the module's sensitivity by adjusting the number of warnings before punishment and how long it takes for warnings to reset.
- Send customizable messages: Inform players about the rules, warn them about their language, or notify them of the consequences of continued profanity.
Key Features:
- Customizable profanity list
- Flexible punishment options (warnings, fines, kicks, bans)
- Swear jar functionality
- Configurable warnings and reset times
- Customizable messages
Benefits:
- Creates a more welcoming and inclusive gaming environment
- Reduces toxic behavior and promotes positive interactions
- Encourages players to be mindful of their language
- Provides a clear and consistent system for moderating profanity
Configuration 10
Settings you fill in when installing the module on a server.
| Setting | Type | Default | Description |
|---|---|---|---|
HVB_Profanity HVB_Profanity | array | ["faggot","shit","gay","cunt","fegg","homo","gey","fag"] | add the words you want |
noPunishmentMessage noPunishmentMessage | string | "Please stop swearing!" | Send a message top make the player know that he should not swear. |
punishmentType punishmentType | string | "kick" | this is to decide what to do kick ban |
banDuration banDuration | number | 300000 | If you choose ban, you can decide how long |
warningsBeforePunishment warningsBeforePunishment | number | 1 | |
warningResetTime warningResetTime | number | 600000 | |
kickMessage kickMessage | string | "Continuing will result in being kicked." | Continuing will result in being kicked. |
banMessage banMessage | string | "Continuing will result in a {duration} ban" | Continuing will result in a {duration} ban |
enableSwearJar enableSwearJar | boolean | false | Enable the swear jar |
swearJarAmount swearJarAmount | number | 0 | swearJarAmount |
Raw config schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [],
"additionalProperties": false,
"properties": {
"HVB_Profanity": {
"title": "HVB_Profanity",
"description": "add the words you want",
"default": [
"faggot",
"shit",
"gay",
"cunt",
"fegg",
"homo",
"gey",
"fag"
],
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"maxItems": 10
},
"noPunishmentMessage": {
"title": "noPunishmentMessage",
"description": "Send a message top make the player know that he should not swear.",
"default": "Please stop swearing!",
"type": "string",
"minLength": 1,
"maxLength": 100
},
"punishmentType": {
"title": "punishmentType",
"description": "this is to decide what to do kick ban",
"default": "kick",
"type": "string",
"enum": [
"kick",
"ban",
"none"
]
},
"banDuration": {
"title": "banDuration",
"description": "If you choose ban, you can decide how long",
"default": 300000,
"x-component": "duration",
"type": "number"
},
"warningsBeforePunishment": {
"title": "warningsBeforePunishment",
"default": 1,
"type": "number",
"maximum": 100
},
"warningResetTime": {
"title": "warningResetTime",
"default": 600000,
"x-component": "duration",
"type": "number"
},
"kickMessage": {
"title": "kickMessage",
"description": "Continuing will result in being kicked.",
"default": "Continuing will result in being kicked.",
"type": "string",
"minLength": 1,
"maxLength": 100
},
"banMessage": {
"title": "banMessage",
"description": "Continuing will result in a {duration} ban",
"default": "Continuing will result in a {duration} ban",
"type": "string",
"minLength": 1,
"maxLength": 100
},
"enableSwearJar": {
"title": "enableSwearJar",
"description": "Enable the swear jar",
"default": false,
"type": "boolean"
},
"swearJarAmount": {
"title": "swearJarAmount",
"description": "swearJarAmount",
"default": 0,
"type": "number"
}
}
} Raw UI schema
{} Hooks 1
Code that runs in reaction to a game or Takaro event.
-
profanityChecker
Hook for chat-message events
Hook source
import { takaro, data, TakaroUserError, checkPermission } from '@takaro/helpers'; async function main() { const { gameServerId, player, pog } = data; if (!pog || !player) return; if (checkPermission(pog, `item_ban_immunity`)) { return; } const existingVariable = await takaro.variable.variableControllerSearch({ filters: { playerId: [player.id], key: ['profanity'], }, }); const { warningsBeforePunishment, noPunishmentMessage, kickMessage, banMessage, HVB_Profanity, punishmentType, banDuration, enableSwearJar, swearJarAmount, warningResetTime } = data.module.userConfig; let currentWarnings = existingVariable.data.data[0] ? parseInt(existingVariable.data.data[0].value, 10) : 0; const now = new Date(); const warningExpireTime = new Date(now.getTime() + warningResetTime); for (const profanity of HVB_Profanity) { if (data.eventData.msg.toLowerCase().includes(profanity)) { currentWarnings++; let warningText = ''; if (punishmentType !== 'none') { warningText = `You have received ${currentWarnings} of ${warningsBeforePunishment} warnings. `; } if (enableSwearJar) { try { await takaro.playerOnGameserver.playerOnGameServerControllerDeductCurrency( gameServerId, player.id, { currency: swearJarAmount } ); warningText += `${swearJarAmount} coins have been added to the swear jar. `; } catch (error) { console.error('Failed to deduct currency:', error); } } if (punishmentType === 'kick') { warningText += kickMessage; } else if (punishmentType === 'ban') { warningText += banMessage.replace('{duration}', banDuration); } else if (punishmentType === 'none') { warningText += noPunishmentMessage; } if (currentWarnings >= warningsBeforePunishment && punishmentType !== 'none') { if (punishmentType === 'kick') { if (existingVariable.data.data.length) { await takaro.variable.variableControllerDelete(existingVariable.data.data[0].id); } await takaro.gameserver.gameServerControllerKickPlayer(gameServerId, player.id, { reason: `You sweared too much`, }); await takaro.gameserver.gameServerControllerSendMessage(gameServerId, { message: `${player.name} has been kicked for profanity.`, }); } else if (punishmentType === 'ban') { if (existingVariable.data.data.length) { await takaro.variable.variableControllerDelete(existingVariable.data.data[0].id); } const expiresAt = new Date(now.getTime() + banDuration); await takaro.player.banControllerCreate({ gameServerId, playerId: player.id, until: expiresAt, reason: `You sweared too much`, }); await takaro.gameserver.gameServerControllerSendMessage(gameServerId, { message: `${player.name} has been banned for profanity.`, }); } } else { await takaro.gameserver.gameServerControllerSendMessage(gameServerId, { message: warningText, opts: { recipient: { gameId: pog.gameId, }, }, }); if (existingVariable.data.data.length) { await takaro.variable.variableControllerUpdate(existingVariable.data.data[0].id, { value: currentWarnings.toString(), expiresAt: warningExpireTime }); } else { await takaro.variable.variableControllerCreate({ playerId: player.id, key: 'profanity', value: currentWarnings.toString(), expiresAt: warningExpireTime }); } } break; } } } await main();
Permissions 1
Roles you can grant to decide who may use what.
-
HVB_PROFANITY_FILTER_v3_HVB_PROFANITY_FILTER_v2_profanity_immunity
This grants immunity for profanity