diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..092f943 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# https://www.lpalmieri.com/posts/fast-rust-docker-builds/ +FROM rust:alpine AS rust +RUN apk add musl-dev openssl-dev +RUN cargo install cargo-chef +WORKDIR app + +FROM rust AS planner +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +FROM rust AS builder +COPY --from=planner /app/recipe.json recipe.json +RUN cargo chef cook --release --recipe-path recipe.json +COPY . . +RUN cargo build --release --bin obsessed-yanqing + + +FROM alpine:latest +RUN apk add --no-cache libc6-compat +COPY --from=builder /app/target/release/obsessed-yanqing /usr/local/bin +ENTRYPOINT [ "/usr/local/bin/obsessed-yanqing" ] \ No newline at end of file diff --git a/src/commands/character.rs b/src/commands/character.rs index 5aa77ac..8091df5 100644 --- a/src/commands/character.rs +++ b/src/commands/character.rs @@ -152,7 +152,7 @@ async fn menu_handler(ctx: Context<'_>, interaction: Arc { - interaction + match interaction .edit_original_interaction_response(&ctx, |d| { match character_embed { None => {} @@ -160,10 +160,13 @@ async fn menu_handler(ctx: Context<'_>, interaction: Arc {} + Err(_) => {} + } } false => { - interaction + match interaction .create_interaction_response(&ctx, |r| { r.interaction_response_data(|d| { match character_embed { @@ -174,12 +177,19 @@ async fn menu_handler(ctx: Context<'_>, interaction: Arc {interaction.delete_followup_message(&ctx, interaction.message.id).await.unwrap();} + Err(_) => {} + } } } - let x = interaction.get_interaction_response(&ctx).await.unwrap().await_component_interaction(&ctx).timeout(Duration::from_secs(10 * 60)).await; + let x = match interaction.get_interaction_response(&ctx).await { + Ok(x) => {x} + Err(_) => return + }; + + let x = x.await_component_interaction(&ctx).timeout(Duration::from_secs(10 * 60)).await; match x { None => {} @@ -208,7 +218,6 @@ async fn choice_interaction_handler(ctx: Context<'_>, message: &ReplyHandle<'_>) return; } }; - let character_string = &interaction.data.values[0]; let character = get_character_data(character_string.to_string()).await.unwrap(); menu_handler(ctx, interaction, character, CharacterTab::Home).await; diff --git a/src/data/character.rs b/src/data/character.rs index 1e61fa5..5b4aff1 100644 --- a/src/data/character.rs +++ b/src/data/character.rs @@ -352,32 +352,44 @@ pub struct Ratings { #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct BuildDaum { - #[serde(rename = "relic_1")] - pub relic_1: String, - #[serde(rename = "relic_2")] - pub relic_2: String, - pub planar: String, - #[serde(rename = "cone_1")] - pub cone_1: String, - #[serde(rename = "cone_2")] - pub cone_2: String, - #[serde(rename = "cone_3")] - pub cone_3: String, - #[serde(rename = "cone_4")] - pub cone_4: String, - #[serde(rename = "cone_5")] - pub cone_5: String, - #[serde(rename = "cone_6")] - pub cone_6: Option, + pub relics: Vec, + pub planars: Vec, + pub cones: Vec, pub body: Vec, pub feet: Vec, pub rope: Vec, pub sphere: Vec, pub comments: String, pub substats: String, + #[serde(rename = "skill_priority")] + pub skill_priority: String, + #[serde(rename = "traces_priority")] + pub traces_priority: String, pub name: String, } +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Relic { + pub relic: String, + #[serde(rename = "relic_2")] + pub relic_2: String, +} + +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Planar { + pub planar: String, +} + +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Cone { + pub cone: String, + #[serde(rename = "super")] + pub super_field: String, +} + #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Body { diff --git a/src/main.rs b/src/main.rs index 9f782c6..afd9332 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ mod commands; mod data; mod utils; use poise::serenity_prelude::GatewayIntents; +use serenity::model::prelude::Activity; use crate::data::Data; #[tokio::main] @@ -18,6 +19,7 @@ async fn main() { }) .setup(|ctx, _ready, framework| { Box::pin(async move { + ctx.set_activity(Activity::listening("/character")).await; poise::builtins::register_globally(ctx, &framework.options().commands).await?; Ok(Data {}) })