Make p.co and p.d reply to the user

This commit is contained in:
2026-03-07 20:15:25 -03:00
parent 014acf55c6
commit e6b99759ce
2 changed files with 18 additions and 2 deletions
+13 -1
View File
@@ -8,7 +8,7 @@ use twilight_model::channel::Message;
use twilight_model::channel::message::{Component as TwilightComponent, Embed}; use twilight_model::channel::message::{Component as TwilightComponent, Embed};
use twilight_model::http::interaction::{InteractionResponse, InteractionResponseType}; use twilight_model::http::interaction::{InteractionResponse, InteractionResponseType};
use twilight_model::id::Id; use twilight_model::id::Id;
use twilight_model::id::marker::{ChannelMarker, InteractionMarker}; use twilight_model::id::marker::{ChannelMarker, InteractionMarker, MessageMarker};
use twilight_util::builder::InteractionResponseDataBuilder; use twilight_util::builder::InteractionResponseDataBuilder;
use crate::framework::interactions::components::{ActionRow, Component}; use crate::framework::interactions::components::{ActionRow, Component};
@@ -21,6 +21,7 @@ pub struct MessageSender<T, E> {
content: Option<String>, content: Option<String>,
embeds: Vec<Embed>, embeds: Vec<Embed>,
reply_to: Option<Id<MessageMarker>>,
// Row index, component // Row index, component
components: Vec<(u8, Arc<dyn Component<T, E>>)>, components: Vec<(u8, Arc<dyn Component<T, E>>)>,
@@ -37,6 +38,7 @@ where
rt, rt,
content: None, content: None,
components: vec![], components: vec![],
reply_to: None,
embeds: vec![], embeds: vec![],
} }
} }
@@ -59,6 +61,12 @@ where
self self
} }
pub fn reply_to(mut self, message_id: Id<MessageMarker>) -> Self {
self.reply_to = Some(message_id);
self
}
pub async fn send(self) -> Result<Response<Message>, Error> { pub async fn send(self) -> Result<Response<Message>, Error> {
let mut builder = self.rt.http.create_message(self.channel_id); let mut builder = self.rt.http.create_message(self.channel_id);
@@ -100,6 +108,10 @@ where
builder = builder.components(&rows); builder = builder.components(&rows);
builder = builder.embeds(&self.embeds); builder = builder.embeds(&self.embeds);
if let Some(reply_to) = self.reply_to {
builder = builder.reply(reply_to);
}
let result = builder.await; let result = builder.await;
if result.is_err() { if result.is_err() {
+5 -1
View File
@@ -103,6 +103,7 @@ impl Command<State, Extras> for CodeOfConductCommand {
) -> Result<(), CommandError> { ) -> Result<(), CommandError> {
ctx.send() ctx.send()
.content("<https://payphone.lat/code-of-conduct>") .content("<https://payphone.lat/code-of-conduct>")
.reply_to(ctx.event.id)
.await?; .await?;
Ok(()) Ok(())
@@ -139,7 +140,10 @@ impl Command<State, Extras> for DonateCommand {
ctx: CommandContext<'_, State, Extras>, ctx: CommandContext<'_, State, Extras>,
_args: &str, _args: &str,
) -> Result<(), CommandError> { ) -> Result<(), CommandError> {
ctx.send().content("<https://ko-fi.com/payphonedev>").await?; ctx.send()
.reply_to(ctx.event.id)
.content("<https://ko-fi.com/payphonedev>")
.await?;
Ok(()) Ok(())
} }