Skip to content

Commit

Permalink
Set Activity
Browse files Browse the repository at this point in the history
Also ran cargo fmt
  • Loading branch information
Scotsguy committed Aug 27, 2019
1 parent 42790cf commit 4379c75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use regex::Regex;
use reqwest::get;

use serenity::{
model::{channel::Message,id::UserId, gateway::Ready},
model::{channel::Message, gateway::Activity, gateway::Ready, id::UserId, user::OnlineStatus},
prelude::*,
utils::Colour,
};
Expand All @@ -14,7 +14,6 @@ use log::{debug, error, info};
mod parsers;
use parsers::PARSERS;


fn main() {
kankyo::load(false).expect("Expected a .env file");
env_logger::init();
Expand Down Expand Up @@ -44,7 +43,7 @@ struct Handler;
impl EventHandler for Handler {
fn message(&self, ctx: Context, msg: Message) {
if msg.author.bot {
return
return;
}

if msg.is_private() {
Expand Down Expand Up @@ -115,10 +114,11 @@ impl EventHandler for Handler {

// TODO: delete on reaction

fn ready(&self, _: Context, ready: Ready) {
fn ready(&self, ctx: Context, ready: Ready) {
info!(
"{}#{} is connected!",
ready.user.name, ready.user.discriminator
);
ctx.set_presence(Some(Activity::playing("DM me!")), OnlineStatus::Online);
}
}
7 changes: 5 additions & 2 deletions src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ fn ram_amount(log: &str) -> Option<(&str, String)> {
let amount = capture.name("amount")?.as_str().parse::<f32>();
let amount = match amount {
Ok(o) => o,
Err(why) => {warn!("Couldn't parse RAM amount: {:?}", why); return None}
Err(why) => {
warn!("Couldn't parse RAM amount: {:?}", why);
return None;
}
};
let amount = amount / 1000.0; // Megabytes => Gigabytes

if amount > 10.0 {
return Some(("⚠", format!("You have allocated {}GB of RAM to Minecraft. [This is too much and can cause lagspikes.](https://vazkii.net/#blog/ram-explanation)", amount )))
return Some(("⚠", format!("You have allocated {}GB of RAM to Minecraft. [This is too much and can cause lagspikes.](https://vazkii.net/#blog/ram-explanation)", amount )));
};
}
None
Expand Down

0 comments on commit 4379c75

Please sign in to comment.