Bot admins in env file #22
2 changed files with 16 additions and 2 deletions
|
@ -12,4 +12,5 @@ login_name = <botname>
|
|||
access_token = <oauth token>
|
||||
bot_channels = <chnl1>,<chnl2>
|
||||
prefix = <prefix>
|
||||
bot_admins = <admins>
|
||||
```
|
|
@ -20,9 +20,22 @@ fn adminvector() -> Vec<String> {
|
|||
dotenv().ok();
|
||||
let mut admins = Vec::new();
|
||||
|
||||
for admin in env::var("bot_admins").unwrap().split(',') {
|
||||
admins.push(String::from(admin))
|
||||
// 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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue