Merge pull request 'Added Ping Role Configuration' (#9) from ping_role into master

Reviewed-on: https://git.etztech.xyz/ZeroHD/HypeBot/pulls/9
master
Joey Hines 2020-07-12 03:27:54 +02:00
commit 08ddd6d8b4
5 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
ALTER TABLE events MODIFY event_desc VARCHAR(255) ;

View File

@ -0,0 +1,2 @@
-- Your SQL goes here
ALTER TABLE events MODIFY event_desc VARCHAR(2050);

View File

@ -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::<Vec<String>>().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 {

View File

@ -13,6 +13,7 @@ pub struct HypeBotConfig {
pub prefix: String,
pub event_channel: u64,
pub event_roles: Vec<u64>,
pub ping_roles: Vec<u64>,
#[serde(deserialize_with = "from_tz_string")]
pub event_timezone: Tz,
pub log_path: String,