feat: Account initialization
- discord: /answer now DM-s user and updated user balance
This commit is contained in:
parent
1ae57ad358
commit
fb9fcfe6d7
3 changed files with 50 additions and 1 deletions
12
discord/src/account.rs
Normal file
12
discord/src/account.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
use squad_quest::{account::Account, config::Config};
|
||||
|
||||
pub fn fetch_or_init_account(conf: &Config, id: String) -> Account {
|
||||
let accounts = conf.load_accounts();
|
||||
match accounts.iter().find(|a| a.id == id) {
|
||||
Some(a) => a.clone(),
|
||||
None => Account {
|
||||
id,
|
||||
..Default::default()
|
||||
},
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue