Refactors for less nesting, slight performance and memory improvement for count command

This commit is contained in:
Roman Moisieiev 2025-09-11 13:39:10 +01:00
parent 6353d77360
commit f3f08962a4
9 changed files with 161 additions and 287 deletions

View file

@ -106,21 +106,19 @@ pub fn get_config() -> Config {
}
}
if let Ok(x) = env::var("COMMITTEE_ROLE") {
if let Ok(x) = x.trim().parse::<u64>() {
if let Ok(x) = x.trim().parse() {
config.committee_role = RoleId::new(x);
}
}
if let Ok(x) = env::var("COMMITTEE_CATEGORY") {
for part in x.split(',') {
if let Ok(x) = part.trim().parse::<u64>() {
config.committee_category.push(ChannelId::new(x));
}
for id in x.split(',').flat_map(|part| part.trim().parse()) {
config.committee_category.push(ChannelId::new(id));
}
}
if let Ok(x) = env::var("COMPSOC_DISCORD") {
if let Ok(x) = x.trim().parse::<u64>() {
config.compsoc_server = GuildId::new(x);
if let Ok(x) = x.trim().parse() {
config.compsoc_server = GuildId::new(x)
}
}