adj adminvector()
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful

This commit is contained in:
ModulatingForce 2024-03-17 19:29:22 -04:00
parent 5fb373c522
commit f7881fa07d
2 changed files with 16 additions and 2 deletions

View file

@ -12,4 +12,5 @@ login_name = <botname>
access_token = <oauth token> access_token = <oauth token>
bot_channels = <chnl1>,<chnl2> bot_channels = <chnl1>,<chnl2>
prefix = <prefix> prefix = <prefix>
bot_admins = <admins>
``` ```

View file

@ -20,9 +20,22 @@ fn adminvector() -> Vec<String> {
dotenv().ok(); dotenv().ok();
let mut admins = Vec::new(); let mut admins = Vec::new();
for admin in env::var("bot_admins").unwrap().split(',') { // for admin in env::var("bot_admins").unwrap().split(',') {
// admins.push(String::from(admin))
// }
// 03.17 - Forcen - Suggesting below instead :
/*
- this will push only if env::var() returns Ok() ;
otherwise (like in Err(_)) do nothing
*/
if let Ok(value) = env::var("bot_admins") {
for admin in value.split(',') {
admins.push(String::from(admin)) admins.push(String::from(admin))
} }
}
admins admins
} }