Correct colour used for help embed

This commit is contained in:
2025-01-30 03:31:47 +00:00
parent ae85cc9fb6
commit e4abd4485b

View File

@@ -1,13 +1,13 @@
use futures::Stream; use futures::Stream;
use cipher_core::repository::RepositoryProvider; use cipher_core::repository::RepositoryProvider;
use poise::CreateReply; use poise::CreateReply;
use serenity::all::Color;
use serenity::all::CreateEmbed; use serenity::all::CreateEmbed;
use serenity::futures::StreamExt; use serenity::futures::StreamExt;
use crate::app::AppCommand; use crate::app::AppCommand;
use crate::app::AppContext; use crate::app::AppContext;
use crate::app::AppError; use crate::app::AppError;
use crate::utils;
async fn autocomplete_command<'a, R> ( async fn autocomplete_command<'a, R> (
ctx: AppContext<'a, R, R::BackendError>, ctx: AppContext<'a, R, R::BackendError>,
@@ -23,7 +23,7 @@ where
/// Show help message. /// Show help message.
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub async fn help<R: RepositoryProvider + Sync>( pub async fn help<R: RepositoryProvider + Send + Sync>(
ctx: AppContext<'_, R, R::BackendError>, ctx: AppContext<'_, R, R::BackendError>,
#[rename = "command"] #[rename = "command"]
#[description = "Command to get help for."] #[description = "Command to get help for."]
@@ -41,15 +41,15 @@ pub async fn help<R: RepositoryProvider + Sync>(
); );
if let Some((command, _, _)) = option_command { if let Some((command, _, _)) = option_command {
command_help_embed(command, all.unwrap_or(false)) command_help_embed(&ctx, command, all.unwrap_or(false)).await
} else { } else {
CreateEmbed::new() CreateEmbed::new()
.title("Help") .title("Help")
.description(format!("Could not find command `/{}`", query)) .description(format!("Could not find command `/{}`", query))
.color(Color::BLURPLE) .color(utils::bot_color(&ctx).await)
} }
} else { } else {
root_help_embed(&ctx, all.unwrap_or(false)) root_help_embed(&ctx, all.unwrap_or(false)).await
}; };
let reply = CreateReply::default() let reply = CreateReply::default()
@@ -61,9 +61,9 @@ pub async fn help<R: RepositoryProvider + Sync>(
Ok(()) Ok(())
} }
fn root_help_embed<R>(ctx: &AppContext<'_, R, R::BackendError>, all: bool) -> CreateEmbed async fn root_help_embed<R>(ctx: &AppContext<'_, R, R::BackendError>, all: bool) -> CreateEmbed
where where
R: RepositoryProvider, R: RepositoryProvider + Send + Sync,
{ {
let mut commands_field_value = String::new(); let mut commands_field_value = String::new();
for command in &ctx.framework().options.commands { for command in &ctx.framework().options.commands {
@@ -87,7 +87,7 @@ where
let mut embed = CreateEmbed::new() let mut embed = CreateEmbed::new()
.title("Help") .title("Help")
.color(Color::BLURPLE); .color(utils::bot_color(&ctx).await);
if !commands_field_value.is_empty() { if !commands_field_value.is_empty() {
embed = embed.field("Commands", commands_field_value, false); embed = embed.field("Commands", commands_field_value, false);
@@ -98,9 +98,13 @@ where
embed embed
} }
fn command_help_embed<R>(command: &AppCommand<R, R::BackendError>, all: bool) -> CreateEmbed async fn command_help_embed<R>(
ctx: &AppContext<'_, R, R::BackendError>,
command: &AppCommand<R, R::BackendError>,
all: bool,
) -> CreateEmbed
where where
R: RepositoryProvider, R: RepositoryProvider + Send + Sync,
{ {
let mut required_parameters_field_value = String::new(); let mut required_parameters_field_value = String::new();
let mut optional_parameters_field_value = String::new(); let mut optional_parameters_field_value = String::new();
@@ -145,7 +149,7 @@ where
let mut embed = CreateEmbed::new() let mut embed = CreateEmbed::new()
.title(format!("Help `/{}`", command.qualified_name)) .title(format!("Help `/{}`", command.qualified_name))
.color(Color::BLURPLE); .color(utils::bot_color(ctx).await);
if let Some(category) = &command.category { if let Some(category) = &command.category {
embed = embed.field("Category", category, false); embed = embed.field("Category", category, false);