Browse Source

Improve issue details embed

master
NGnius (Graham) 3 years ago
parent
commit
a7325137a0
1 changed files with 20 additions and 8 deletions
  1. +20
    -8
      src/gitea_command.rs

+ 20
- 8
src/gitea_command.rs View File

@@ -123,8 +123,15 @@ pub fn gitea_issue(interaction: &Interaction) -> InteractionResponse {
if desc.len() > 2000 {
desc = desc[..2000].to_string() + "...";
}
// build tags field
let mut tags = Vec::new();
for t in resp.labels {
tags.push(format!("{}", &t.name));
}
let tag_str = tags.join(", ");
// build embed
let embed = Embed {
title: Some(format!("{} #{}", &repo_name, index)),
title: Some(format!("Issue #{}", index)),
type_: None,
description: Some(desc),
url: None,
@@ -141,18 +148,23 @@ pub fn gitea_issue(interaction: &Interaction) -> InteractionResponse {
provider: None,
author: Some(EmbedAuthor {
name: Some(resp.title.clone()),
url: Some(format!("https://git.exmods.org/{}/{}/issues/{}", &username, &repo_name, index)),
url: Some(resp.html_url),
icon_url: None,
proxy_icon_url: None
}),
fields: None,
/*fields: Some(vec![
//fields: None,
fields: Some(vec![
EmbedField {
name: "Download".to_string(),
value: asset_str,
name: "Labels".to_string(),
value: tag_str,
inline: Some(true)
}
])*/
},
EmbedField {
name: "Repository".to_string(),
value: format!("[{}](https://git.exmods.org/{}/{})", resp.repository.name, &username, &repo_name),
inline: Some(true)
},
])
};
return InteractionResponse::ChannelMessageWithSource {
data: Some(InteractionApplicationCommandCallbackData {


Loading…
Cancel
Save