Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 21, 2025

This PR implements a comprehensive badge/achievement system for the UDC Bot, allowing administrators to create, assign, and manage user badges through Discord slash commands.

Features Implemented

Database Layer

  • Badge Entity: Stores badge information (ID, Title, Description, CreatedAt)
  • UserBadge Entity: Junction table linking users to badges with award metadata
  • Auto-table Creation: Database tables are automatically created on bot startup
  • MySQL Integration: Uses existing Insight.Database ORM patterns

Admin Slash Commands

All commands require Discord Administrator permissions and use the /badge command group:

  • /badge create [title] [description] - Create new badges with validation
  • /badge assign [user] [badge] - Assign badges to users with duplicate prevention
  • /badge remove [user] [badge] - Remove badges from users
  • /badge list - Display all available badges
  • /badge view [user] - Show a user's earned badges

User Experience

  • Rich embed responses with appropriate colors and formatting
  • DM notifications when users receive badges
  • Comprehensive error handling and validation
  • Clear feedback for all operations

Database Schema

The system creates two new tables:

-- Stores badge definitions
CREATE TABLE `badges` (
    `Id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `Title` varchar(100) NOT NULL,
    `Description` text NOT NULL,
    `CreatedAt` datetime NOT NULL,
    PRIMARY KEY (`Id`),
    UNIQUE KEY `Title` (`Title`)
);

-- Links users to their badges
CREATE TABLE `user_badges` (
    `Id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `UserID` varchar(32) NOT NULL,
    `BadgeId` int(11) UNSIGNED NOT NULL,
    `AwardedAt` datetime NOT NULL,
    `AwardedBy` varchar(32) NOT NULL,
    PRIMARY KEY (`Id`),
    UNIQUE KEY `user_badge_unique` (`UserID`, `BadgeId`),
    FOREIGN KEY (`BadgeId`) REFERENCES `badges` (`Id`) ON DELETE CASCADE
);

Usage Examples

/badge create title:"UDC Jam Winner" description:"Won a UDC Game Jam competition"
/badge assign user:@JohnDoe badge:"UDC Jam Winner"
/badge view user:@JohnDoe
/badge list
/badge remove user:@JohnDoe badge:"UDC Jam Winner"

Technical Details

  • Follows existing codebase patterns and conventions
  • Integrates with current dependency injection system
  • Uses established logging and error handling patterns
  • Maintains consistency with Discord.NET interaction patterns
  • Includes comprehensive input validation and security measures

The system is production-ready and will be immediately available to administrators once deployed.

Fixes #341.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Pierre-Demessence <1756398+Pierre-Demessence@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Achievement/Badge System Implement Achievement/Badge System with Admin Commands Jul 21, 2025
@Copilot Copilot AI requested a review from Pierre-Demessence July 21, 2025 13:48
Copilot finished work on behalf of Pierre-Demessence July 21, 2025 13:48
@Pierre-Demessence
Copy link
Member

/deploy_dev

Copy link

🚀 Starting deployment of Unity-Developer-Community/UDC-Bot:copilot/fix-341 to development...

@Pierre-Demessence
Copy link
Member

@copilot A few modifications:

  • Users should be able to view the list of badges

  • Anyone should be able to view the list of badges of another user

    • (Still only Admins can Create/Assign badges).
  • Admins should be able to edit a Badge too.

  • A new property: Whether badges should be public or not (default to public).

    • Private badges are only visible to Admins (on the full list + on the list of badges assigned to an user). Other users won't see them.

Co-authored-by: Pierre-Demessence <1756398+Pierre-Demessence@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jul 26, 2025

@copilot A few modifications:

  • Users should be able to view the list of badges
  • Anyone should be able to view the list of badges of another user
    ...

I've implemented all the requested modifications to the badge system:

Users can now view the list of badges - Removed admin requirement from /badge list
Anyone can view badges of other users - Removed admin requirement from /badge view
Admins can edit badges - Added new /badge edit command for administrators
Public/private badge visibility - Added IsPublic property (defaults to public)
Private badge filtering - Private badges only visible to admins with 🔒 indicator

Key Changes:

  • Badge visibility system with automatic database migration
  • Permission restructuring: list/view commands are now public, admin commands require permissions
  • Private badges show lock icon (🔒) for admins and are filtered from non-admin views
  • Enhanced embed responses showing visibility status and counts
  • Public responses for engagement vs ephemeral for admin operations

The system is backward compatible and will automatically add the IsPublic column to existing installations. Commit: e2061f0

Copilot finished work on behalf of Pierre-Demessence July 26, 2025 21:15
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.

Achievement/Badge System
2 participants