0.5.0 embed, help, refractor

This commit is contained in:
2024-02-13 18:44:01 +01:00
parent d75c5bc9a2
commit 8fa86b0182
24 changed files with 341 additions and 94 deletions

37
src/commands/embeds.rs Normal file
View File

@@ -0,0 +1,37 @@
use crate::{Context, Error};
use serenity::{builder::{CreateEmbedAuthor, CreateEmbedFooter}, model::{Colour, Timestamp}};
use poise::serenity_prelude::CreateEmbed;
use poise::CreateReply;
pub async fn fail(ctx: Context<'_>, err: String) -> Result<(), Error> {
ctx.send(
CreateReply::default().embed(error_embed(ctx, &format!("Failed: {:?}", err)).await.unwrap())
).await?;
Ok(())
}
pub async fn error_embed(ctx: Context<'_>, msg: &str) -> Result<CreateEmbed, Error> {
let embed = CreateEmbed::default()
.author(CreateEmbedAuthor::new("Something went wrong!").icon_url(ctx.author().clone().face()))
.colour(Colour::from_rgb(255, 58, 97))
.title("Oopsie, Doopsie!")
.description(msg)
.timestamp(Timestamp::now())
.footer(CreateEmbedFooter::new(ctx.cache().current_user().name.to_string()).icon_url(ctx.cache().current_user().face()));
Ok(embed)
}
pub async fn embed(ctx: Context<'_>, author: &str, description: &str, title: &str) -> Result<CreateEmbed, Error> {
let embed = CreateEmbed::default()
.author(CreateEmbedAuthor::new(author).icon_url(ctx.author().clone().face()))
.colour(Colour::from_rgb(255, 58, 97))
.title(title)
.description(description)
.timestamp(Timestamp::now())
.footer(CreateEmbedFooter::new(ctx.cache().current_user().name.to_string()).icon_url(ctx.cache().current_user().face()));
Ok(embed)
}