summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSefa Eyeoglu <[email protected]>2024-05-27 11:28:51 +0200
committerGitHub <[email protected]>2024-05-27 09:28:51 +0000
commit8c5a91a7a3c946ce5314816ca050043c5a603f94 (patch)
treefb09decaadf091f204e77ac0d09c8808032ac6e1 /src
parent5e23c92215d7db92b7e998d9dc1c2dc8a3329166 (diff)
feat: add PR link to response (#2)
This also displays the response as an embed. Signed-off-by: Sefa Eyeoglu <[email protected]> Co-authored-by: seth <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/command/track.rs10
-rw-r--r--src/http/github.rs3
2 files changed, 10 insertions, 3 deletions
diff --git a/src/command/track.rs b/src/command/track.rs
index 6217043..45715f4 100644
--- a/src/command/track.rs
+++ b/src/command/track.rs
@@ -1,7 +1,8 @@
-use crate::http::{Client, GithubClientExt};
+use crate::http::{Client, GithubClientExt, GITHUB_URL};
use eyre::Result;
use futures::future::try_join_all;
+use serenity::all::CreateEmbed;
use serenity::builder::{CreateCommand, CreateCommandOption, CreateInteractionResponseFollowup};
use serenity::model::application::{
CommandInteraction, CommandOptionType, InstallationContext, ResolvedOption, ResolvedValue,
@@ -111,7 +112,12 @@ pub async fn respond(ctx: &Context, http: &Client, command: &CommandInteraction)
}))
.await?;
- CreateInteractionResponseFollowup::new().content(statuses.join("\n"))
+ let embed = CreateEmbed::new()
+ .title(format!("Nixpkgs PR #{} Status", *pr))
+ .url(format!("{GITHUB_URL}/{REPO_OWNER}/{REPO_NAME}/pull/{}", pr))
+ .description(statuses.join("\n"));
+
+ CreateInteractionResponseFollowup::new().embed(embed)
}
} else {
CreateInteractionResponseFollowup::new().content("Please provide a valid commit!")
diff --git a/src/http/github.rs b/src/http/github.rs
index bdb363e..8d4f18a 100644
--- a/src/http/github.rs
+++ b/src/http/github.rs
@@ -2,7 +2,8 @@ use super::{Error, HttpClientExt};
use serde::Deserialize;
-const GITHUB_API: &str = "https://api.github.com";
+pub const GITHUB_URL: &str = "https://github.com";
+pub const GITHUB_API: &str = "https://api.github.com";
/// Bad version of `/repos/{owner}/{repo}/{compare}/{ref}...{ref}`
#[derive(Deserialize)]