feat: add images from https://thearchive.gg
This commit is contained in:
parent
80cbda2510
commit
66d965a439
62
src/main.rs
62
src/main.rs
|
@ -1,5 +1,5 @@
|
||||||
use bluearch_recruitment::banner::{Banner, BannerBuilder};
|
use bluearch_recruitment::banner::{Banner, BannerBuilder};
|
||||||
use bluearch_recruitment::gacha::{GachaBuilder, Recruitment};
|
use bluearch_recruitment::gacha::{GachaBuilder, Rarity, Recruitment};
|
||||||
use bluearch_recruitment::i18n::Language;
|
use bluearch_recruitment::i18n::Language;
|
||||||
use bluearch_recruitment::student::Student;
|
use bluearch_recruitment::student::Student;
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
|
@ -20,7 +20,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
struct General;
|
struct General;
|
||||||
|
|
||||||
#[group]
|
#[group]
|
||||||
#[commands(roll, roll10, banner)]
|
#[commands(roll, banner)]
|
||||||
struct RecruitmentCommands;
|
struct RecruitmentCommands;
|
||||||
|
|
||||||
struct Handler;
|
struct Handler;
|
||||||
|
@ -29,6 +29,7 @@ struct Handler;
|
||||||
impl EventHandler for Handler {}
|
impl EventHandler for Handler {}
|
||||||
|
|
||||||
const STUDENTS_JSON: &str = include_str!("../data/students.json");
|
const STUDENTS_JSON: &str = include_str!("../data/students.json");
|
||||||
|
const CDN_URL: &str = "https://rerollcdn.com/BlueArchive";
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref STUDENTS: Vec<Student> = serde_json::from_str(STUDENTS_JSON).unwrap();
|
static ref STUDENTS: Vec<Student> = serde_json::from_str(STUDENTS_JSON).unwrap();
|
||||||
|
@ -89,38 +90,43 @@ async fn roll(ctx: &Context, msg: &Message) -> CommandResult {
|
||||||
let author_name = format!("{}#{}", msg.author.name, msg.author.discriminator);
|
let author_name = format!("{}#{}", msg.author.name, msg.author.discriminator);
|
||||||
info!("{} Requested a single roll", author_name);
|
info!("{} Requested a single roll", author_name);
|
||||||
|
|
||||||
|
let channel = msg.channel_id;
|
||||||
let student = BANNER.roll();
|
let student = BANNER.roll();
|
||||||
|
|
||||||
msg.reply(
|
let eng_name = student.name.get(Language::English).unwrap();
|
||||||
ctx,
|
let url_name = if eng_name == "Junko" {
|
||||||
format!(
|
"Zunko"
|
||||||
"You Pulled: {} {}",
|
} else {
|
||||||
student.name.get(Language::English).unwrap(),
|
&eng_name
|
||||||
student.rarity
|
};
|
||||||
),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
let img_url = format!("{}/Characters/{}.png", CDN_URL, url_name);
|
||||||
}
|
let title_url = format!("https://www.thearchive.gg/characters/{}", url_name);
|
||||||
|
let icon_url = format!("{}/Icons/icon-brand.png", CDN_URL);
|
||||||
|
|
||||||
#[command]
|
let rarity_str = match student.rarity {
|
||||||
async fn roll10(ctx: &Context, msg: &Message) -> CommandResult {
|
Rarity::One => ":star:",
|
||||||
let author_name = format!("{}#{}", msg.author.name, msg.author.discriminator);
|
Rarity::Two => ":star::star:",
|
||||||
info!("{} Requested a 10-roll", author_name);
|
Rarity::Three => ":star::star::star:",
|
||||||
|
};
|
||||||
|
|
||||||
let students = BANNER.roll10();
|
channel
|
||||||
let mut response = "You Pulled:\n".to_string();
|
.send_message(ctx, |m| {
|
||||||
|
m.reference_message(msg).embed(|embed| {
|
||||||
|
embed
|
||||||
|
.image(img_url)
|
||||||
|
.title(format!("{}", student.name))
|
||||||
|
.description(format!("{}\t{}", eng_name, rarity_str))
|
||||||
|
.url(title_url)
|
||||||
|
.footer(|footer| {
|
||||||
|
footer
|
||||||
|
.icon_url(icon_url)
|
||||||
|
.text("Image Source: https://thearchive.gg")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
for student in students.iter() {
|
|
||||||
response += &format!(
|
|
||||||
"{} {}\n",
|
|
||||||
student.name.get(Language::English).unwrap(),
|
|
||||||
student.rarity
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg.reply(ctx, response).await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue