Implement swear filter #8
Labels
areas::processes::conduct
Code of conduct
areas::product::source
Affects product source (code, etc)
tasks::features::new
New features
tasks::review::functional
Alignment with specifications and requirements
Background
The existing
swearFilter.ts
code is an event-based filter that checks incoming messages (and their embeds) for profanity. If profanity is found, it attempts to DM the user a warning and deletes the message. If the user’s DMs are blocked, it posts a temporary warning message in the channel and then self-destructs that warning. Finally, it logs the action to the#bot-stuff
channel.This behavior is triggered automatically whenever a message is created or updated (as a partial message). The filter uses a hardcoded regex (
swearRegex
) to detect swears and awhitelist
regex to exclude certain words. It also checks channel permissions to determine if the channel is visible to the@everyone
role before taking action.However, the new codebase needs to leverage modern slash commands and channel autocompletion features, rather than passively watching all messages.
Problem
/swearfilter add-word
,/swearfilter remove-word
,/swearfilter set-channel
, etc.).Solution
1. Outline of the New Swear Filter Flow
Instead of handling all messages directly in an event handler, we’ll separate:
Proposed approach:
/swearfilter enable
or/swearfilter disable
/swearfilter add-word <word>
/swearfilter remove-word <word>
/swearfilter whitelist add <word>
/swearfilter whitelist remove <word>
/swearfilter set-channels <channel...>
– uses channel autocomplete to let moderators pick channels in which the filter applies.messageCreate
ormessageUpdate
event:swearRegex
or dynamically built list of banned words, skipping any that match the whitelist.#bot-stuff
).2. Slash Command Specs
/swearfilter enable
MANAGE_GUILD
permission)./swearfilter disable
/swearfilter add-word <word>
/swearfilter remove-word <word>
/swearfilter whitelist add <word>
/swearfilter whitelist remove <word>
/swearfilter set-channels
channels
(Autocomplete) – allows the admin to pick from current channels in the server.3. Data Structures
The text was updated successfully, but these errors were encountered: