Skip to content

Commit ed9b70b

Browse files
committed
fix
1 parent b8d14c0 commit ed9b70b

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/ai_message.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ fn get_user_or_default(database: &r2d2::Pool<SqliteConnectionManager>, user_id:
154154
})
155155
.unwrap_or_else(|| User {
156156
id: user_id,
157-
name: "Unknown".to_owned(),
158157
level: 0,
159158
xp: 0,
159+
social_credit: 0,
160+
name: "Unknown".to_owned(),
160161
})
161162
}
162163

src/database.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ pub struct User {
6161
#[sql(constraint = "NOT NULL")]
6262
pub level: i32,
6363

64-
#[sql(constraint = "NOT NULL")]
65-
pub name: String,
66-
6764
#[sql(constraint = "NOT NULL")]
6865
pub xp: i32,
66+
67+
#[sql(constraint = "DEFAULT 0")]
68+
pub social_credit: i32,
69+
70+
#[sql(constraint = "DEFAULT ''")]
71+
pub name: String,
6972
}
7073

7174
#[derive(CreateTableSql, InsertSync, UpdateSync, Serialize, Deserialize, Debug, PartialEq)]

src/message_handler.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,10 @@ pub async fn handle_message(
171171
} else {
172172
let new_user = User {
173173
id: msg.author.id.get(),
174-
name: msg.author.name.clone(),
175174
level: 0,
176175
xp: 0,
176+
social_credit: 0,
177+
name: msg.author.name.clone(),
177178
};
178179
new_user.insert_sync(&*locked_state.db.get()?)?;
179180
}

0 commit comments

Comments
 (0)