diff --git a/README.md b/README.md index d2fee77..bc07568 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ prefix = "~" event_channel = 0 # List of roles that can use the bot event_roles = [0] +# List of roles to ping when a new event is posted +ping_roles = [0] # Timezone to display events, supported timezones can be found at https://docs.rs/chrono-tz/0.5.1/chrono_tz/#modules event_timezone = "America/New_York" # Path to place logs in diff --git a/migrations/2020-07-10-032139_bigger_desc_field/down.sql b/migrations/2020-07-10-032139_bigger_desc_field/down.sql new file mode 100644 index 0000000..a0b6650 --- /dev/null +++ b/migrations/2020-07-10-032139_bigger_desc_field/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE events MODIFY event_desc VARCHAR(255) ; \ No newline at end of file diff --git a/migrations/2020-07-10-032139_bigger_desc_field/up.sql b/migrations/2020-07-10-032139_bigger_desc_field/up.sql new file mode 100644 index 0000000..3fee40b --- /dev/null +++ b/migrations/2020-07-10-032139_bigger_desc_field/up.sql @@ -0,0 +1,2 @@ +-- Your SQL goes here +ALTER TABLE events MODIFY event_desc VARCHAR(2050); \ No newline at end of file diff --git a/src/discord/mod.rs b/src/discord/mod.rs index 9251946..c7879a6 100644 --- a/src/discord/mod.rs +++ b/src/discord/mod.rs @@ -42,7 +42,8 @@ pub fn send_message_to_reaction_users(ctx: &Context, reaction: &Reaction, msg_te let event = match get_event_by_msg_id(db_link, message_id) { Ok(event) => event, - Err(_) => { + Err(e) => { + error!("Error getting event from reaction {}", e); return; } }; @@ -97,6 +98,10 @@ pub fn send_event_msg( let native_time = utc_time.with_timezone(&config.event_timezone); + let ping_roles = config.ping_roles.clone().into_iter().map(|role| { + format!("<@&{}>", role) + }).collect::>().join(" "); + // Send message let msg = channel.id().send_message(&http, |m| { m.embed(|e| { @@ -114,7 +119,7 @@ pub fn send_event_msg( .timestamp(utc_time.to_rfc3339()) .field("Location", &event.event_loc, true) .field("Organizer", &event.organizer, true) - }) + }).content(ping_roles) })?; if react { diff --git a/src/hypebot_config.rs b/src/hypebot_config.rs index c510e74..0b07737 100644 --- a/src/hypebot_config.rs +++ b/src/hypebot_config.rs @@ -13,6 +13,7 @@ pub struct HypeBotConfig { pub prefix: String, pub event_channel: u64, pub event_roles: Vec, + pub ping_roles: Vec, #[serde(deserialize_with = "from_tz_string")] pub event_timezone: Tz, pub log_path: String,