From 08e95274efbdc37c76626e06335c9eff435628b1 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 8 Jul 2022 20:23:49 +0200 Subject: [PATCH] style: fix `multiplicies` of names --- configuration.example.json | 2 +- configuration.schema.json | 2 +- src/main.rs | 22 +++++++++++----------- src/model/application.rs | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/configuration.example.json b/configuration.example.json index c09ade2..9267855 100644 --- a/configuration.example.json +++ b/configuration.example.json @@ -13,7 +13,7 @@ } } ], - "message_responders": [ + "message_responses": [ { "includes": { "channels": [0], diff --git a/configuration.schema.json b/configuration.schema.json index e00ae84..f4f92b8 100644 --- a/configuration.schema.json +++ b/configuration.schema.json @@ -48,7 +48,7 @@ "minItems": 1, "uniqueItems": true }, - "message_responders": { + "message_responses": { "type": "array", "items": { "type": "object", diff --git a/src/main.rs b/src/main.rs index d50ce68..05fc0a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,7 @@ impl EventHandler for Handler { let new_config = load_configuration(); configuration.administrators = new_config.administrators; - configuration.message_responders = new_config.message_responders; + configuration.message_responses = new_config.message_responses; configuration.thread_introductions = new_config.thread_introductions; "Successfully reloaded configuration.".to_string() @@ -121,20 +121,20 @@ impl EventHandler for Handler { return; } - if let Some(responder) = - get_configuration_lock(&ctx).await.read().await.message_responders.iter().find( - |&responder| { + if let Some(message_response) = + get_configuration_lock(&ctx).await.read().await.message_responses.iter().find( + |&response| { // check if the message was sent in a channel that is included in the responder - responder.includes.channels.iter().any(|&channel_id| channel_id == msg.channel_id.0) + response.includes.channels.iter().any(|&channel_id| channel_id == msg.channel_id.0) // check if the message was sent by a user that is not excluded from the responder - && !responder.excludes.roles.iter().any(|&role_id| role_id == msg.author.id.0) + && !response.excludes.roles.iter().any(|&role_id| role_id == msg.author.id.0) // check if the message does not match any of the excludes - && !contains_match(&responder.excludes.match_field, &msg.content) + && !contains_match(&response.excludes.match_field, &msg.content) // check if the message matches any of the includes - && contains_match(&responder.includes.match_field, &msg.content) + && contains_match(&response.includes.match_field, &msg.content) }, ) { - let min_age = responder.condition.user.server_age; + let min_age = message_response.condition.user.server_age; if min_age != 0 { let joined_at = ctx @@ -157,7 +157,7 @@ impl EventHandler for Handler { msg.channel_id .send_message(&ctx.http, |m| { m.reference_message(&msg); - match &responder.response.embed { + match &message_response.response.embed { Some(embed) => m.embed(|e| { e.title(&embed.title) .description(&embed.description) @@ -175,7 +175,7 @@ impl EventHandler for Handler { a.name(&embed.author.name).icon_url(&embed.author.icon_url) }) }), - None => m.content(responder.response.message.as_ref().unwrap()), + None => m.content(message_response.response.message.as_ref().unwrap()), } }) .await diff --git a/src/model/application.rs b/src/model/application.rs index 68a6266..4dd68be 100644 --- a/src/model/application.rs +++ b/src/model/application.rs @@ -9,7 +9,7 @@ pub struct Configuration { pub discord_authorization_token: String, pub administrators: Administrators, pub thread_introductions: Vec, - pub message_responders: Vec, + pub message_responses: Vec, } impl Configuration { @@ -49,7 +49,7 @@ pub struct Introduction { } #[derive(Serialize, Deserialize)] -pub struct MessageResponder { +pub struct MessageResponse { pub includes: Includes, pub excludes: Excludes, pub condition: Condition,