// use chrono::Utc; use crate::core::colours; use crate::core::consts::*; // use crate::core::consts::DB as db; use crate::core::model::*; // use crate::core::utils::*; // use forecast::Icon::*; // use forecast::Units; // use rand::prelude::*; // use serenity::CACHE; // use serenity::client::bridge::gateway::ShardId; use serenity::framework::standard::{ Args, Command, CommandError, CommandOptions }; use serenity::model::{ channel::Message, // guild::Role, }; use serenity::prelude::{ Context, // Mentionable }; // use std::f64::NAN; use std::sync::Arc; // use sys_info; // use sysinfo::{ // ProcessExt, // SystemExt, // System, // get_current_pid // }; pub struct Anime; impl Command for Anime { fn options(&self) -> Arc { let default = CommandOptions::default(); let options = CommandOptions { desc: Some("Want to share an anime? Results provided by kitsu.io.".to_string()), usage: Some("".to_string()), example: Some("darling in the franxx".to_string()), ..default }; Arc::new(options) } fn execute(&self, ctx: &mut Context, message: &Message, args: Args) -> Result<(), CommandError> { use kitsu::model::Status::*; let data = ctx.data.lock(); message.channel_id.broadcast_typing()?; if let Some(api) = data.get::() { let res = api.anime(args.full())?; if let Some(anime) = res.data.first() { let status = match anime.attributes.status { Some(stat) => { match stat { Current => "Current", Finished => "Complete", TBA => "To Be Announced", Unreleased => "Unreleased", Upcoming => "Upcoming", }}, None => "Status Not Found", }; let cover_url = match anime.attributes.cover_image.clone() { Some(cover) => { match cover.original { Some(url) => url, None => String::new(), }}, None => String::new(), }; message.channel_id.send_message(|m| m .embed(|e| e .title(anime.attributes.canonical_title.clone()) .url(anime.url()) .description(format!("{}\n\n{}\n**Score:** {}\n**Status:** {}", anime.attributes.synopsis, if let Some(count) = anime.attributes.episode_count { let mut out = format!("**Episodes:** {}", count); if let Some(length) = anime.attributes.episode_length { out.push_str(format!(" ({} min/ep)", length).as_str()); } out } else { String::from("Episode Information Not Found") }, anime.attributes.average_rating.clone().unwrap_or(String::from("Not Found")), status )) .thumbnail(cover_url) .colour(*colours::MAIN) ))?; } } else { failed!(API_FAIL); } Ok(()) } } pub struct DadJoke; impl Command for DadJoke { fn options(&self) -> Arc { let default = CommandOptions::default(); let options = CommandOptions { desc: Some("Who would voluntarily want a dad joke...".to_string()), ..default }; Arc::new(options) } fn execute(&self, ctx: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> { let data = ctx.data.lock(); if let Some(api) = data.get::() { let res = api.joke()?; message.channel_id.say(res)?; } else { failed!(API_FAIL); } Ok(()) } } pub struct Douse; impl Command for Douse { fn options(&self) -> Arc { let default = CommandOptions::default(); let options = CommandOptions { ..default }; Arc::new(options) } fn execute(&self, _ctx: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> { message.channel_id.send_message(|m| m .embed(|e| e .colour(*colours::MAIN) .image("https://i.pinimg.com/originals/6a/c8/26/6ac826e3d0cbd64eb4f42c12a73fcdb8.gif") ))?; Ok(()) } } pub struct Manga; impl Command for Manga { fn options(&self) -> Arc { let default = CommandOptions::default(); let options = CommandOptions { desc: Some("Need info about a manga? Results provided by kitsu.io".to_string()), usage: Some("".to_string()), example: Some("deathnote".to_string()), ..default }; Arc::new(options) } fn execute(&self, ctx: &mut Context, message: &Message, args: Args) -> Result<(), CommandError> { use kitsu::model::Status::*; let data = ctx.data.lock(); message.channel_id.broadcast_typing()?; if let Some(api) = data.get::() { let res = api.manga(args.full())?; if let Some(manga) = res.data.first() { let status = match manga.attributes.status { Some(stat) => { match stat { Current => "Current", Finished => "Complete", TBA => "To Be Announced", Unreleased => "Unreleased", Upcoming => "Upcoming", }}, None => "Status Not Found", }; let cover_url = match manga.attributes.cover_image.clone() { Some(cover) => { match cover.original { Some(url) => url, None => String::new(), }}, None => String::new(), }; message.channel_id.send_message(|m| m .embed(|e| e .title(manga.attributes.canonical_title.clone()) .url(manga.url()) .description(format!("{}\n\n**Volumes:** {}\n**Chapters:** {}\n**Score:** {}\n**Status:** {}", manga.attributes.synopsis, manga.attributes.volume_count.map_or(String::from("Not Found"), |count| count.to_string()), manga.attributes.chapter_count.map_or(String::from("Not Found"), |count| count.to_string()), manga.attributes.average_rating.clone().unwrap_or(String::from("Not Found")), status )) .thumbnail(cover_url) .colour(*colours::MAIN) ))?; } } else { failed!(API_FAIL); } Ok(()) } } // pub struct Waifu; // impl Command for Waifu { // fn options(&self) -> Arc { // let default = CommandOptions::default(); // let options = CommandOptions { // desc: Some("I'll give you random waifu and backstory generated by a neural network, so don't get too attached.".to_string()), // ..default // }; // Arc::new(options) // } // fn execute(&self, ctx: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> { // let data = ctx.data.lock(); // if let Some(api) = data.get::() { // let res = api.waifu_backstory()?; // message.channel_id.send_message(|m| m // .embed(|e| e // // .image(res.image) // .description(res) // ))?; // } else { failed!(API_FAIL); } // Ok(()) // } // } // pub struct DateFact; // impl Command for DateFact { // fn options(&self) -> Arc { // let default = CommandOptions::default(); // let options = CommandOptions { // desc: Some("A fun fact about a fun date.".to_string()), // ..default // }; // Arc::new(options) // } // fn execute(&self, _: &mut Context, message: &Message, args: Args) -> Result<(), CommandError> { // let to_say = args; // message.channel_id.say(uwufied)?; // Ok(()) // } // }