summaryrefslogtreecommitdiff
path: root/src/utils.rs
diff options
context:
space:
mode:
authorseth <[email protected]>2024-01-20 21:19:09 -0500
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2024-01-21 10:54:13 +0000
commitc6162b77fb113634359acc9dd6b7d6b4191fc5d4 (patch)
tree92e9e75006ed2b7d28197c34c9ca925a97b628dc /src/utils.rs
parentd903e7760a316d5476e65db0e6058dc5c8698cc2 (diff)
refactor: adjust to poise 0.6.1
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/utils.rs b/src/utils.rs
index 1a96359..8312b6c 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,7 +1,8 @@
use crate::{colors, Context};
use color_eyre::eyre::{eyre, Result};
-use poise::serenity_prelude as serenity;
+use poise::serenity_prelude::{self as serenity, CreateEmbedAuthor, CreateEmbedFooter};
+use poise::CreateReply;
use rand::seq::SliceRandom;
use serenity::{CreateEmbed, Message};
use url::Url;
@@ -44,15 +45,14 @@ pub async fn send_url_as_embed(ctx: Context<'_>, url: String) -> Result<()> {
.unwrap_or("image")
.replace("%20", " ");
- ctx.send(|c| {
- c.embed(|e| {
- e.title(title)
- .image(&url)
- .url(url)
- .color(colors::Colors::Blue)
- })
- })
- .await?;
+ let embed = CreateEmbed::new()
+ .title(title)
+ .image(&url)
+ .url(url)
+ .color(colors::Colors::Blue);
+ let reply = CreateReply::default().embed(embed);
+
+ ctx.send(reply).await?;
Ok(())
}
@@ -87,29 +87,29 @@ pub async fn resolve_message_to_embed(ctx: &serenity::Context, msg: &Message) ->
let attachments_len = msg.attachments.len();
- let mut embed = msg
+ let embed = msg
.embeds
.first()
.map(|embed| CreateEmbed::from(embed.clone()))
.unwrap_or_default();
- embed.author(|author| author.name(&msg.author.name).icon_url(&msg.author.face()));
+ let author = CreateEmbedAuthor::new(&msg.author.name).icon_url(msg.author.face());
+ let mut embed = embed.clone().author(author);
if let Some(color) = color {
- embed.color(color);
+ embed = embed.color(color);
}
if let Some(attachment) = attached_image {
- embed.image(attachment);
+ embed = embed.image(attachment);
}
if attachments_len > 1 {
- embed.footer(|footer| {
- // yes it will say '1 attachments' no i do not care
- footer.text(format!("{attachments_len} attachments"))
- });
+ embed = embed.footer(CreateEmbedFooter::new(format!(
+ "{attachments_len} attachments"
+ )));
}
- embed.description(truncated_content);
+ embed = embed.description(truncated_content);
embed
}