From f7881fa07d5ff5a6d1295eaf80c88214437df746 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Sun, 17 Mar 2024 19:29:22 -0400 Subject: [PATCH] adj adminvector() --- README.md | 1 + src/core/identity.rs | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8637fdc..33fdb59 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,5 @@ login_name = access_token = bot_channels = , prefix = +bot_admins = ``` \ No newline at end of file diff --git a/src/core/identity.rs b/src/core/identity.rs index 6392eb3..42bc4c7 100644 --- a/src/core/identity.rs +++ b/src/core/identity.rs @@ -20,9 +20,22 @@ fn adminvector() -> Vec { 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 }