Repository navigation
Conversation
Moved synchronous `fs.readFileSync` for bad words out of the hot path in `messageCreate`. It is now cached globally. Also caches the lowercased strings to prevent unnecessary CPU overhead on every message. Included benchmark script `benchmarks/moderation_bench.js`.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- `scripts/register-commands.js` now exits cleanly with `0` when `CLIENT_ID` or `BOT_TOKEN` are missing, instead of failing the CI. - The Discord webhook notifications in `.github/workflows/node.js.yml` now only run if the `DISCORD_WEBHOOK_URL` environment variable is not empty, preventing `curl` from failing with `Malformed input to a URL function`.
💡 What: Moved
fs.readFileSyncout of the moderation event handler formessageCreateand introduced a global cachebadWordsCache. Also optimized it to pre-compute the lowercased versions of the words rather than calling.toLowerCase()in every check loop.🎯 Why: The previous code synchronously loaded and parsed
badwords.jsonon every single message event, causing significant CPU blocking and disk I/O on active servers.📊 Measured Improvement: In a benchmark using 1000 items in
badwords.jsonand 1000 events, execution time went from 435ms down to 330ms (a ~25% decrease in overall event processing time overhead).PR created automatically by Jules for task 11927522952074606270 started by @Lacikika