Commit b52907ba authored by tec's avatar tec

Add anouncement

parent 341a5522
...@@ -15,6 +15,9 @@ static MAIN_CHANNEL: serenity::model::id::ChannelId = ...@@ -15,6 +15,9 @@ static MAIN_CHANNEL: serenity::model::id::ChannelId =
// #the-corner // #the-corner
static WELCOME_CHANNEL: serenity::model::id::ChannelId = static WELCOME_CHANNEL: serenity::model::id::ChannelId =
serenity::model::id::ChannelId(606351613816209418); serenity::model::id::ChannelId(606351613816209418);
// #general
static ANNOUNCEMENT_CHANNEL: serenity::model::id::ChannelId =
serenity::model::id::ChannelId(606351521117896706);
static BOT_ID: u64 = 607078903969742848; static BOT_ID: u64 = 607078903969742848;
...@@ -261,6 +264,7 @@ fn update_motion( ...@@ -261,6 +264,7 @@ fn update_motion(
let old_embed = msg.embeds[0].clone(); let old_embed = msg.embeds[0].clone();
let topic = old_embed.clone().title.unwrap(); let topic = old_embed.clone().title.unwrap();
println!( println!(
" {:10} {:6} {} on {}", " {:10} {:6} {} on {}",
user.name, user.name,
...@@ -268,11 +272,38 @@ fn update_motion( ...@@ -268,11 +272,38 @@ fn update_motion(
reaction.emoji.as_data().as_str(), reaction.emoji.as_data().as_str(),
topic topic
); );
let update_status = |e: &mut serenity::builder::CreateEmbed,
status: &str,
last_status_full: String,
topic: &str| {
let last_status = last_status_full.lines().next().expect("No previous status");
if last_status == status {
e.field("Status", last_status_full, true);
} else {
e.field(
"Status",
format!("{}\n_was_ {}", status, last_status_full),
true,
);
println!("Motion to {} now {}", topic, status);
//
let mut message = MessageBuilder::new();
message.push_bold(topic);
message.push(" is now ");
message.push_bold(status);
message.push_italic(format!(" (was {})", last_status));
if let Err(why) = ANNOUNCEMENT_CHANNEL.say(&ctx.http, message.build()) {
println!("Error sending message: {:?}", why);
};
}
};
if let Err(why) = msg.edit(ctx, |m| { if let Err(why) = msg.edit(ctx, |m| {
m.embed(|e| { m.embed(|e| {
e.title(&topic); e.title(&topic);
e.description(old_embed.description.unwrap()); e.description(old_embed.description.unwrap());
let last_status = old_embed let last_status_full = old_embed
.fields .fields
.iter() .iter()
.filter(|f| f.name == "Status") .filter(|f| f.name == "Status")
...@@ -282,23 +313,13 @@ fn update_motion( ...@@ -282,23 +313,13 @@ fn update_motion(
.value; .value;
if for_strength > (VOTE_POOL_SIZE / 2) as f32 { if for_strength > (VOTE_POOL_SIZE / 2) as f32 {
e.colour(serenity::utils::Colour::TEAL); e.colour(serenity::utils::Colour::TEAL);
e.field("Status", format!("Passed\n_was_ {}", last_status), true); update_status(e, "Passed", last_status_full, &topic);
println!("Motion to {} PASSED", &topic)
} else if against_strength + abstain_strength > (VOTE_POOL_SIZE / 2) as f32 { } else if against_strength + abstain_strength > (VOTE_POOL_SIZE / 2) as f32 {
e.colour(serenity::utils::Colour::RED); e.colour(serenity::utils::Colour::RED);
e.field("Status", format!("Failed\n_was_ {}", last_status), true); update_status(e, "Failed", last_status_full, &topic);
println!("Motion to {} FAILED", &topic)
} else { } else {
e.colour(serenity::utils::Colour::GOLD); e.colour(serenity::utils::Colour::GOLD);
e.field( update_status(e, "Under Consideration", last_status_full, &topic);
"Status",
if last_status != "Under Consideration" {
format!("Under Consideration\n_was_ {}", last_status)
} else {
"Under Consideration".to_string()
},
true,
);
} }
e.field( e.field(
format!( format!(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment