Skip to content

Feature/capr 24 create standard embed utilities - #52

Merged
shamikkarkhanis merged 3 commits into
mainfrom
feature/capr-24-create-standard-embed-utilities
Jan 31, 2026
Merged

Feature/capr 24 create standard embed utilities#52
shamikkarkhanis merged 3 commits into
mainfrom
feature/capr-24-create-standard-embed-utilities

Conversation

@shamikkarkhanis

@shamikkarkhanis shamikkarkhanis commented Jan 31, 2026

Copy link
Copy Markdown
Member

Summary by Sourcery

Introduce shared embed utilities for consistent Discord message styling and adopt them in profile interactions.

New Features:

  • Add a standardised set of helper functions to create status-specific Discord embeds (error, success, info, warning, important, unmarked, ignored).

Enhancements:

  • Update profile create, update, show, and delete flows to use the new status embeds for all user-facing responses, including combined status and profile display messages.

Tests:

  • Add unit tests covering all embed helper variants to verify titles, descriptions, and colours.

@sourcery-ai

sourcery-ai Bot commented Jan 31, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Introduces a shared embed utility module with standardized status-styled Discord embeds and refactors profile interaction flows to use these helpers for consistent messaging while adding tests to validate embed construction.

File-Level Changes

Change Details Files
Add centralized helpers for creating standardized status embeds for Discord messages.
  • Define color constants for various status types (error, success, resolved, info, warning, important, unmarked, ignored).
  • Implement small factory functions that construct discord.Embed objects with a given title, description, and appropriate status color.
  • Document each helper with docstrings to clarify purpose and returned type.
capy_discord/utils/embeds.py
Refactor profile command flows to use standardized embed helpers instead of raw string messages.
  • Replace plain ephemeral string responses for profile existence/absence checks with error_embed-based embeds.
  • Change profile deletion success and cancellation responses to use success_embed and info_embed helpers respectively.
  • Update profile submission flow to respond with a success_embed plus the profile display embed using the embeds list parameter.
capy_discord/exts/profile/profile.py
Add unit tests to ensure embed helper functions construct embeds with the correct titles, descriptions, and colors.
  • Create tests for each helper verifying embed.title, embed.description, and embed.color.
  • Use discord.Color factory methods in assertions to mirror the constants used in the implementation.
tests/capy_discord/utils/test_embeds.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • In embeds.py, STATUS_SUCCESS is defined but not used while success_embed uses STATUS_RESOLVED, which is also green; consider either using STATUS_SUCCESS in success_embed or removing/renaming one of the constants to avoid confusion and dead code.
  • Now that the profile flows use standard embeds, consider checking for any remaining plain-string response messages in this extension (and nearby ones) that should also be migrated to these helpers for consistency in UX and styling.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `embeds.py`, `STATUS_SUCCESS` is defined but not used while `success_embed` uses `STATUS_RESOLVED`, which is also green; consider either using `STATUS_SUCCESS` in `success_embed` or removing/renaming one of the constants to avoid confusion and dead code.
- Now that the profile flows use standard embeds, consider checking for any remaining plain-string response messages in this extension (and nearby ones) that should also be migrated to these helpers for consistency in UX and styling.

## Individual Comments

### Comment 1
<location> `capy_discord/utils/embeds.py:6-15` </location>
<code_context>
+import discord
+
+STATUS_ERROR = discord.Color.red()
+STATUS_SUCCESS = discord.Color.green()
+STATUS_RESOLVED = discord.Color.green()
+STATUS_INFO = discord.Color.blue()
+STATUS_WARNING = discord.Color.yellow()
+STATUS_IMPORTANT = discord.Color.gold()
+STATUS_UNMARKED = discord.Color.light_grey()
+STATUS_IGNORED = discord.Color.greyple()
+
+
+def error_embed(title: str, description: str) -> discord.Embed:
+    """Create an error status embed.
+
+    Args:
+        title: The title of the embed.
+        description: The description of the embed.
+
+    Returns:
+        discord.Embed: The created embed.
+    """
+    return discord.Embed(title=title, description=description, color=STATUS_ERROR)
+
+
+def success_embed(title: str, description: str) -> discord.Embed:
+    """Create a success status embed.
+
</code_context>

<issue_to_address>
**issue:** Align the success color constant and `success_embed` implementation

`STATUS_SUCCESS` and `STATUS_RESOLVED` are both green, but `success_embed` uses `STATUS_RESOLVED`, leaving `STATUS_SUCCESS` unused and the naming unclear. Consider either having `success_embed` use `STATUS_SUCCESS`, or removing `STATUS_SUCCESS` and renaming `STATUS_RESOLVED` if that’s the canonical success color.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread capy_discord/utils/embeds.py
@shamikkarkhanis
shamikkarkhanis merged commit d250d34 into main Jan 31, 2026
4 checks passed
@shamikkarkhanis
shamikkarkhanis deleted the feature/capr-24-create-standard-embed-utilities branch January 31, 2026 04:58
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.

1 participant