Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 13, 2025

Kick Enforcement and Notification Improvements ✅

This PR implements comprehensive improvements to the kick enforcement and notification system based on community feedback. All requirements from the issue have been successfully addressed.

✅ Completed Features

1. Enhanced Enforcement Records

  • ✅ Added RuleViolated field with standardized rule categories
  • ✅ Added IsPubliclyVisible flag for opt-in public logs
  • ✅ Added DMNotificationSent and DMNotificationAttempted tracking
  • ✅ Clear separation between user-facing messages and internal auditor notes
  • ✅ Backward compatible with existing enforcement records

2. Direct Message Notifications

  • ✅ Automatically sends Discord DM when enforcement action is taken
  • ✅ Includes: reason, rule violated, duration, expiry, access restrictions
  • ✅ Graceful DM failure handling (logs but doesn't block enforcement)
  • ✅ Prompts users to check /whoami for full details
  • ✅ Tracks notification delivery success/failure for review

3. Enhanced /whoami Display

  • ✅ Prominent display of active enforcement actions at top
  • ✅ Clear warning indicators with red color for active suspensions
  • ✅ Shows expiry times with relative timestamps
  • ✅ Updated footer reminds users to check DMs
  • ✅ Improved visibility and user experience
  • ✅ Properly escapes user-provided text to prevent formatting issues

4. Public Enforcement Logs

  • ✅ Opt-in public log system (disabled by default)
  • ✅ Privacy-filtered: excludes mod identity and internal notes
  • ✅ Configurable retention period (default 90 days)
  • ✅ Supports querying active, recent, and historical entries
  • ✅ Public read with server-only write permissions
  • ✅ Ephemeral storage with automatic cleanup

5. Moderator UX Improvements

  • ✅ 10 standardized rule violation categories (properly copied to prevent modification)
  • AddRecordWithOptions() for advanced enforcement creation
  • ✅ Consistent enforcement reasons across moderators
  • ✅ Maintains backward compatibility

6. Metrics and Tracking

  • ✅ Tracks enforcement counts by type (kicks, suspensions, voidings)
  • ✅ Records actions by rule category
  • ✅ Daily metrics with unique user counts
  • ✅ Notification delivery success/failure tracking
  • ✅ Automatic cleanup of old metrics (90 day retention)
  • ✅ Fixed unique user counting to properly handle save/load cycles
  • ✅ Foundation for measuring player attrition vs enforcement visibility

7. Comprehensive Testing

  • ✅ Unit tests for notification message formatting
  • ✅ Tests for AddRecordWithOptions functionality
  • ✅ Tests for notification status tracking
  • ✅ Tests for public log privacy filtering
  • ✅ Tests for metrics tracking
  • ✅ Backward compatibility tests
  • ✅ All existing tests continue to pass

8. Security & Code Quality

  • ✅ Code review completed and feedback addressed
  • ✅ Validation for edge cases (negative durations, etc.)
  • ✅ Improved error messaging
  • ✅ Privacy protections for moderator identity
  • ✅ Access control considerations documented
  • ✅ No secrets or PII exposed in public logs
  • ✅ All review comments addressed

🎯 Impact

Player Transparency:

  • Players now receive immediate DM notifications explaining enforcement actions
  • Clear information about reason, duration, and how to appeal
  • Enhanced /whoami makes it easy to check enforcement status

Moderator Tools:

  • Standardized rule categories ensure consistent enforcement
  • Metrics help identify patterns and improve moderation
  • Public logs (when enabled) increase accountability

Privacy & Fairness:

  • Moderator identity never disclosed in public logs
  • Internal notes remain confidential
  • Opt-in system gives guilds control over visibility

Educational Focus:

  • Enforcement messages educate players about rules
  • Clear expiry times reduce confusion
  • /whoami prompt guides players to more information
Original prompt

This section details on the original issue you should resolve

<issue_title>Improvements to kick enforcement and notifications</issue_title>
<issue_description>### Summary

  • Current kick enforcement displays only "Kicked from server," leaving
    players uninformed about specific reasons.
  • Proposed enhancements include: DM/direct messaging, /whoami
    clarification, and detailed—but privacy-conscious—logging.
  • Community feedback prioritizes player transparency, mod privacy,
    and fairness, suggesting public visibility only for action reason/
    duration.

Recommendations

  • Extend enhancements to include a public "suspension/kick log"
    that records only reason and duration (no personal information).
    Store logs ephemerally (temporary/opt-in, no history).
  • Improve visibility of /whoami and DM notifications; prompt
    players on Discord/game interface after enforcement.
  • Focus log and notification changes on rule clarity—using enforcement
    records for education, not as public shaming.
  • Streamline moderator UX: enable selection of rules as enforcement
    reasons (makes reasons objective/consistent).
  • Never disclose mod identity or moderator notes in public logs;
    keep audit logs restricted for accountability.
  • Measure effects: track player attrition and quitting in relation
    to log/notification visibility.

Suggested Issue Comment

Based on community feedback, recommend implementing a public
"suspension/kick log" displaying only enforcement reason and
duration (no player/mod identifiers), available to relevant linked
Discord or in-game users, and by default ephemeral or opt-in. Ensure
/whoami and DM notifications are highly visible following actions,
with clear prompts. Consider improvements to moderator UX—such as
selecting enforcement reasons from standardized rule list. These
changes aim to educate, not shame, increase rule transparency, and
mitigate mod abuse perceptions, while reducing confusion/toxicity.
Request tracking metrics for player attrition versus visibility
of logs/notifications.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits December 13, 2025 19:01
Co-authored-by: thesprockee <962164+thesprockee@users.noreply.github.com>
Co-authored-by: thesprockee <962164+thesprockee@users.noreply.github.com>
Co-authored-by: thesprockee <962164+thesprockee@users.noreply.github.com>
Co-authored-by: thesprockee <962164+thesprockee@users.noreply.github.com>
Co-authored-by: thesprockee <962164+thesprockee@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance kick enforcement and notifications for players Add enforcement notifications, public logs, and metrics tracking Dec 13, 2025
Copilot AI requested a review from thesprockee December 13, 2025 19:26
@thesprockee thesprockee marked this pull request as ready for review December 13, 2025 19:33
Copilot AI review requested due to automatic review settings December 13, 2025 19:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances enforcement action transparency by adding DM notifications, public logs, and metrics tracking while protecting moderator privacy. Players will now receive detailed direct messages explaining their enforcement actions instead of generic "Kicked from server" messages, and can view active suspensions prominently in the /whoami command.

Key Changes:

  • Added standardized rule categories, notification messaging, and opt-in public visibility tracking to enforcement records
  • Implemented DM notification system with Discord message formatting and delivery status tracking
  • Enhanced /whoami display with prominent active suspension warnings at the top with red color coding

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
server/evr_enforcement_record.go Added new fields for rule tracking, public visibility, and DM notification status; implemented GetNotificationMessage() for formatted user notifications and GetStandardEnforcementRules() for standardized rule categories
server/evr_enforcement_journal.go Added AddRecordWithOptions() for extended record creation with new fields; implemented SendEnforcementNotification() for DM delivery and UpdateRecordNotificationStatus() for tracking notification attempts
server/evr_enforcement_public_log.go New file implementing opt-in public enforcement logs with privacy filtering (excludes moderator identity and internal notes), 90-day retention, and public read permissions
server/evr_enforcement_public_log_test.go Comprehensive test coverage for public log functionality including privacy filtering, retention cleanup, and active/voided entry filtering
server/evr_enforcement_metrics.go New file implementing enforcement metrics tracking with daily statistics, unique user counts, notification success/failure rates, and rule-based categorization
server/evr_enforcement_notification_test.go Test coverage for notification message generation, record options, notification status tracking, and backward compatibility
server/evr_discord_appbot_whoami.go Enhanced suspension embed to display active suspensions prominently at top with warning indicators, red color coding, and updated footer text prompting users to check DMs
server/evr_discord_appbot_handlers.go Integrated notification sending, public log recording, and metrics tracking into the enforcement action handler with appropriate error handling
server/evr_matchmaker_process_test.go Removed unused zap import (code cleanup)

Comment on lines 120 to 150
// recordActionForDate records an action for today's date
func (m *EnforcementActionMetrics) recordActionForDate(userID, actionType string) {
dateStr := time.Now().UTC().Format("2006-01-02")

daily, exists := m.ActionsByDate[dateStr]
if !exists {
daily = DailyMetrics{
Date: dateStr,
AffectedUsers: make(map[string]bool),
}
}

switch actionType {
case "kick":
daily.Kicks++
case "suspension":
daily.Suspensions++
case "voiding":
daily.Voidings++
}

// Track unique users
if userID != "" {
if daily.AffectedUsers == nil {
daily.AffectedUsers = make(map[string]bool)
}
daily.AffectedUsers[userID] = true
daily.UniqueUsersAffected = len(daily.AffectedUsers)
}

m.ActionsByDate[dateStr] = daily
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AffectedUsers field in DailyMetrics is marked with json:"-" so it won't be serialized to storage. When metrics are loaded from storage and deserialized, this field will be nil. However, at lines 143-146, the code checks if AffectedUsers is nil and initializes it if needed before using it. This means the UniqueUsersAffected count stored in the JSON will be preserved, but the actual set of user IDs will be lost after a save/load cycle. This could lead to undercounting unique users if metrics are loaded and then new actions are added, since the previously affected users won't be in the set anymore. Consider either serializing this field (with appropriate privacy controls) or recalculating the unique count differently.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 576ab46. Changed the logic to increment UniqueUsersAffected only when adding a new user to the session map, rather than recalculating from the map length. This preserves the stored count across save/load cycles while still tracking unique users accurately within each session. Added comments to document this behavior.

thesprockee and others added 4 commits December 13, 2025 18:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Andrew Bates <a@sprock.io>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Andrew Bates <a@sprock.io>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Andrew Bates <a@sprock.io>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Andrew Bates <a@sprock.io>
@thesprockee
Copy link
Member

@copilot apply changes based on the comments in this thread

Co-authored-by: thesprockee <962164+thesprockee@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 15, 2025

@copilot apply changes based on the comments in this thread

Changes applied in commit 576ab46. The metrics unique user counting has been fixed to properly handle save/load cycles by incrementing the count only when adding new users rather than recalculating from the length of the map. This prevents undercounting after a reload since the AffectedUsers map is not serialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvements to kick enforcement and notifications

2 participants