Add links to reply embeds and fix nitro custom server avatars not displaying

This commit is contained in:
2025-08-24 15:45:54 -03:00
parent fc9bbcc87c
commit 39120a65fa
6 changed files with 56 additions and 6 deletions
+8
View File
@@ -27,6 +27,7 @@ pub fn first_warning_embed(
app.icon,
app.bot.as_ref().unwrap().id.get(),
app.bot.as_ref().unwrap().discriminator as u64,
None
)
).unwrap()
)
@@ -49,6 +50,7 @@ pub fn first_warning_embed(
app.icon,
app.bot.as_ref().unwrap().id.get(),
app.bot.as_ref().unwrap().discriminator as u64,
None
))
.unwrap()
)
@@ -70,6 +72,7 @@ pub fn repeat_warning_embed(
app.icon,
app.bot.as_ref().unwrap().id.get(),
app.bot.as_ref().unwrap().discriminator as u64,
None
)
).unwrap()
)
@@ -92,6 +95,7 @@ pub fn repeat_warning_embed(
app.icon,
app.bot.as_ref().unwrap().id.get(),
app.bot.as_ref().unwrap().discriminator as u64,
None
))
.unwrap()
)
@@ -113,6 +117,7 @@ pub fn first_ban_embed(
app.icon,
app.bot.as_ref().unwrap().id.get(),
app.bot.as_ref().unwrap().discriminator as u64,
None
)
).unwrap()
)
@@ -135,6 +140,7 @@ pub fn first_ban_embed(
app.icon,
app.bot.as_ref().unwrap().id.get(),
app.bot.as_ref().unwrap().discriminator as u64,
None
))
.unwrap()
)
@@ -156,6 +162,7 @@ pub fn final_ban_embed(
app.icon,
app.bot.as_ref().unwrap().id.get(),
app.bot.as_ref().unwrap().discriminator as u64,
None
)
).unwrap()
)
@@ -178,6 +185,7 @@ pub fn final_ban_embed(
app.icon,
app.bot.as_ref().unwrap().id.get(),
app.bot.as_ref().unwrap().discriminator as u64,
None
)
).unwrap()
)
+29 -2
View File
@@ -6,6 +6,7 @@ use time::{Duration, UtcDateTime};
use twilight_http::{api_error::ApiError, error::ErrorType};
use twilight_model::{
gateway::payload::incoming::{MessageCreate, MessageDelete, MessageUpdate},
guild,
id::Id,
};
use twilight_util::{
@@ -110,6 +111,10 @@ impl OnMessageHandler<State, Extras> for CallMessageHandler {
return Ok(());
}
let Some(guild_id) = event.guild_id else {
return Ok(());
};
let prefixes = rt
.get_prefixes(event.guild_id.map(|i| i.get()), Some(event.author.id.get()))
.await;
@@ -252,6 +257,11 @@ impl OnMessageHandler<State, Extras> for CallMessageHandler {
.or(event.author.avatar),
event.author.id.get(),
event.author.discriminator as u64,
event
.member
.as_ref()
.and_then(|member| member.avatar)
.map(|_| guild_id.get()),
),
user.is_masked,
&rt.state.db,
@@ -291,7 +301,11 @@ impl OnMessageHandler<State, Extras> for CallMessageHandler {
let mut embeds = vec![];
if let Some(replying_to) = replying_to {
if let Some(propagation_channel_id) = replying_to.data.propagation_channel_id {
if let Some((propagation_channel_id, propagation_message_id)) = replying_to
.data
.propagation_channel_id
.zip(replying_to.data.propagation_message_id)
{
let (display_name, avatar_url) =
if let Some(mask) = replying_to.data.author_mask {
(
@@ -313,11 +327,24 @@ impl OnMessageHandler<State, Extras> for CallMessageHandler {
)
};
let message_link = if i64_to_u64(propagation_channel_id) == channel.id {
format!(
"https://discord.com/channels/{}/{}/{}",
opposite_channel.server_id, opposite_channel.id, replying_to.message_id
)
} else {
format!(
"https://discord.com/channels/{}/{}/{}",
channel.server_id, propagation_channel_id, propagation_message_id
)
};
embeds.push(
EmbedBuilder::new()
.author(
EmbedAuthorBuilder::new(format!("Replying to {display_name}",))
.icon_url(ImageSource::url(avatar_url).unwrap()),
.icon_url(ImageSource::url(avatar_url).unwrap())
.url(message_link),
)
.color(COLOR_WHITE)
.description(ellipse(replying_to.data.content, 100))