pub fn create_embed_error(error_message: &str) -> CreateReplyExpand description
⚙️ Function: Creates an embed displaying an error message for Discord interactions.
This function constructs a Discord embed message that displays a given error message in a formatted way.
The embed is styled with a red color to indicate an error and includes a default title of “Error”.
The embed is returned as part of a CreateReply, which can be sent to a Discord channel.
§Parameters:
error_message: A string slice containing the error message to be displayed in the embed’s description. This message is intended to provide feedback to the user, typically in case of API errors, invalid inputs, or other issues encountered during the bot’s execution.
§Returns:
CreateReply: A response object that includes the error embed. This is ready to be sent to a Discord channel.
§⚠️ Notes:
- The embed’s color is set to red (
0xff0000) to visually signify an error. - The title of the embed is always set to “Error”, and the provided
error_messageis used in the description. - The function is primarily used to provide user-friendly error messages in response to invalid inputs or issues in API calls.
§Example:
let error_reply = create_embed_error("Failed to fetch data from the Riot API.");
ctx.send(error_reply).await?;The resulting embed message will look like this:
❌ **Error**
Failed to fetch data from the Riot API.