-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/capr 24 create standard embed utilities #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shamikkarkhanis
merged 3 commits into
main
from
feature/capr-24-create-standard-embed-utilities
Jan 31, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| """Standard embed utilities for consistent message styling.""" | ||
|
|
||
| import discord | ||
|
|
||
| STATUS_ERROR = discord.Color.red() | ||
| STATUS_SUCCESS = 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. | ||
|
|
||
| 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_SUCCESS) | ||
|
|
||
|
|
||
| def info_embed(title: str, description: str) -> discord.Embed: | ||
| """Create an info 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_INFO) | ||
|
|
||
|
|
||
| def warning_embed(title: str, description: str) -> discord.Embed: | ||
| """Create a warning 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_WARNING) | ||
|
|
||
|
|
||
| def important_embed(title: str, description: str) -> discord.Embed: | ||
| """Create an important 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_IMPORTANT) | ||
|
|
||
|
|
||
| def unmarked_embed(title: str, description: str) -> discord.Embed: | ||
| """Create an unmarked 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_UNMARKED) | ||
|
|
||
|
|
||
| def ignored_embed(title: str, description: str) -> discord.Embed: | ||
| """Create an ignored 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_IGNORED) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| """Tests for the embed utility functions.""" | ||
|
|
||
| import discord | ||
|
|
||
| from capy_discord.utils.embeds import ( | ||
| error_embed, | ||
| ignored_embed, | ||
| important_embed, | ||
| info_embed, | ||
| success_embed, | ||
| unmarked_embed, | ||
| warning_embed, | ||
| ) | ||
|
|
||
|
|
||
| def test_error_embed(): | ||
| """Test the error_embed helper function.""" | ||
| title = "Error Title" | ||
| description = "Error Description" | ||
| embed = error_embed(title, description) | ||
|
|
||
| assert embed.title == title | ||
| assert embed.description == description | ||
| assert embed.color == discord.Color.red() | ||
|
|
||
|
|
||
| def test_success_embed(): | ||
| """Test the success_embed helper function.""" | ||
| title = "Success Title" | ||
| description = "Success Description" | ||
| embed = success_embed(title, description) | ||
|
|
||
| assert embed.title == title | ||
| assert embed.description == description | ||
| assert embed.color == discord.Color.green() | ||
|
|
||
|
|
||
| def test_info_embed(): | ||
| """Test the info_embed helper function.""" | ||
| title = "Info Title" | ||
| description = "Info Description" | ||
| embed = info_embed(title, description) | ||
|
|
||
| assert embed.title == title | ||
| assert embed.description == description | ||
| assert embed.color == discord.Color.blue() | ||
|
|
||
|
|
||
| def test_warning_embed(): | ||
| """Test the warning_embed helper function.""" | ||
| title = "Warning Title" | ||
| description = "Warning Description" | ||
| embed = warning_embed(title, description) | ||
|
|
||
| assert embed.title == title | ||
| assert embed.description == description | ||
| assert embed.color == discord.Color.yellow() | ||
|
|
||
|
|
||
| def test_important_embed(): | ||
| """Test the important_embed helper function.""" | ||
| title = "Important Title" | ||
| description = "Important Description" | ||
| embed = important_embed(title, description) | ||
|
|
||
| assert embed.title == title | ||
| assert embed.description == description | ||
| assert embed.color == discord.Color.gold() | ||
|
|
||
|
|
||
| def test_unmarked_embed(): | ||
| """Test the unmarked_embed helper function.""" | ||
| title = "Unmarked Title" | ||
| description = "Unmarked Description" | ||
| embed = unmarked_embed(title, description) | ||
|
|
||
| assert embed.title == title | ||
| assert embed.description == description | ||
| assert embed.color == discord.Color.light_grey() | ||
|
|
||
|
|
||
| def test_ignored_embed(): | ||
| """Test the ignored_embed helper function.""" | ||
| title = "Ignored Title" | ||
| description = "Ignored Description" | ||
| embed = ignored_embed(title, description) | ||
|
|
||
| assert embed.title == title | ||
| assert embed.description == description | ||
| assert embed.color == discord.Color.greyple() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.