-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Background
The devChatterWarning.ts
script is a TypeScript module designed for a Discord bot that moderates the content of messages in specific channels. Its primary purpose is to ensure that technical discussions and disallowed domains are kept out of non-technical channels. If a violation is detected, the bot issues a warning to the user and guides them to the appropriate channels for their discussions.
This script is implemented using the discord.js
library and leverages regular expressions and web requests to validate the content of messages. The current implementation uses traditional message event handling and text-based commands.
Problem
The existing implementation has the following limitations:
- Outdated Command Style: The bot uses legacy commands like
!portal
, which are less intuitive and modern compared to Discord's slash commands. - Static Domain Handling: The script relies on a hardcoded list of disallowed domains for validation. This makes it inflexible to updates without code changes.
- Reliance on Manual Regular Expressions: The script parses content using several custom regular expressions, which can be error-prone and difficult to maintain.
Solution
To modernize and improve this feature, we propose re-implementing it using Discord's slash commands and a more modular, flexible design.
Functional Requirements
- Automated Moderation: Retain automated detection of disallowed domains and technical discussions in non-technical channels.
- (optional) Dynamic Domain Handling: Use a configurable and extensible system for managing disallowed and allowed domains/keywords.
Technical Requirements
- Slash Command Framework: Use the modern interaction APIs for warnings.
- Testing and Logging: Implement unit tests for easier debugging and maintenance.
- (optional) Configuration Management: Use a SettingsBase to manage allowed or disallowed domains and keywords, implement behind a slash command.
- (optional) Content Validation: Replace manual regular expressions with a utility class or library for parsing and validating message content.
Spec Outline
Automated Moderation
- Triggers:
- Message in a monitored channel.
- Domain matches the disallowed list.
- Technical discussion detected in a non-technical channel.
- Actions:
- Warn the user with an "only you can see this" bot message, a reply, or DM.
- Use the existing warning message. Guide the user to the appropriate channels.
- Deletion Monitoring: Automatically delete the warning if the offending message is removed.
Modular Architecture
- Message Processor: A utility for parsing and validating message content.
- Warning Handler: Manages warning messages and user interactions.
- Domain Validator: Checks message content against allowed and disallowed domains dynamically.
Example Workflow
- User posts a message in
user-chat
containing a disallowed domain. - Bot detects the domain and issues a warning with a prompt to move the discussion.
- If the message is deleted, the bot removes the associated warning.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status