Skip to content

Commit

Permalink
Deserialize number from string
Browse files Browse the repository at this point in the history
i hate JS and it not being able to handle integers
  • Loading branch information
tazz4843 committed Dec 21, 2023
1 parent 24c3305 commit 695ef7d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 10 additions & 3 deletions scripty_botlists/src/lists/top_gg/models.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use serde_aux::field_attributes::deserialize_number_from_string;

#[derive(Debug, Serialize, Copy, Clone)]
pub struct PostStats {
pub server_count: usize,
Expand All @@ -6,10 +8,15 @@ pub struct PostStats {

#[derive(Debug, Deserialize, Copy, Clone)]
pub struct IncomingWebhook {
pub bot: u64,
pub user: u64,
#[serde(deserialize_with = "deserialize_number_from_string")]
pub bot: u64,

#[serde(deserialize_with = "deserialize_number_from_string")]
pub user: u64,

#[serde(rename = "type")]
pub kind: VoteWebhookType,
pub kind: VoteWebhookType,

pub is_weekend: bool,
}

Expand Down
9 changes: 7 additions & 2 deletions scripty_botlists/src/lists/wumpus_store/models.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use serde_aux::field_attributes::deserialize_number_from_string;

#[derive(Debug, Deserialize, Copy, Clone)]
#[serde(rename_all = "camelCase")]
pub struct IncomingWebhook {
pub test_webhook: bool,
pub user_id: u64,
pub bot_id: u64,

#[serde(deserialize_with = "deserialize_number_from_string")]
pub user_id: u64,
#[serde(deserialize_with = "deserialize_number_from_string")]
pub bot_id: u64,
}

0 comments on commit 695ef7d

Please sign in to comment.