feat: add images from https://thearchive.gg
This commit is contained in:
parent
80cbda2510
commit
66d965a439
66
src/main.rs
66
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,41 +90,46 @@ 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
|
};
|
||||||
),
|
|
||||||
)
|
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);
|
||||||
|
|
||||||
|
let rarity_str = match student.rarity {
|
||||||
|
Rarity::One => ":star:",
|
||||||
|
Rarity::Two => ":star::star:",
|
||||||
|
Rarity::Three => ":star::star::star:",
|
||||||
|
};
|
||||||
|
|
||||||
|
channel
|
||||||
|
.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?;
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
|
||||||
async fn roll10(ctx: &Context, msg: &Message) -> CommandResult {
|
|
||||||
let author_name = format!("{}#{}", msg.author.name, msg.author.discriminator);
|
|
||||||
info!("{} Requested a 10-roll", author_name);
|
|
||||||
|
|
||||||
let students = BANNER.roll10();
|
|
||||||
let mut response = "You Pulled:\n".to_string();
|
|
||||||
|
|
||||||
for student in students.iter() {
|
|
||||||
response += &format!(
|
|
||||||
"{} {}\n",
|
|
||||||
student.name.get(Language::English).unwrap(),
|
|
||||||
student.rarity
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg.reply(ctx, response).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
async fn banner(ctx: &Context, msg: &Message) -> CommandResult {
|
async fn banner(ctx: &Context, msg: &Message) -> CommandResult {
|
||||||
msg.reply(ctx, format!("Current Banner: {}", BANNER.name))
|
msg.reply(ctx, format!("Current Banner: {}", BANNER.name))
|
||||||
|
|
Loading…
Reference in New Issue