From e6de3ed9f9df40d651db0b2ab4594178132383b8 Mon Sep 17 00:00:00 2001 From: Agatha Rose Date: Thu, 11 Jun 2020 19:04:32 +0300 Subject: [PATCH] Add embed docs --- src/embed-docs.txt | 18 ++++++++++++++++++ src/main.rs | 13 ++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/embed-docs.txt diff --git a/src/embed-docs.txt b/src/embed-docs.txt new file mode 100644 index 0000000..3ca89f1 --- /dev/null +++ b/src/embed-docs.txt @@ -0,0 +1,18 @@ +Embed formatting: + +```toml +owo embed +author = ["author's name", "link to author's icon"] # you can pass an empty string for either +colour = "ff0000" # color in hex format +description = "embed decription" +fields = [ + ["name", "value", inline], # inline is boolean; name can be up to 256 chars, value up to 1024 + ... +] +footer = [ "footer text", "link to footer icon" ] # you can pass an empty string for either +image = "link to image" +thumbnail = "link to image" +timestamp = "YYYY-MM-DDTHH:MM:SS" # ISO 8601 format +title = "title text" +url = "title link (not required)" +``` diff --git a/src/main.rs b/src/main.rs index 04a2945..8ac9dd1 100755 --- a/src/main.rs +++ b/src/main.rs @@ -253,6 +253,7 @@ fn host(ctx: &mut Context, message: &Message) -> CommandResult { fn embed(ctx: &mut Context, message: &Message, args: Args) -> CommandResult { use serde::Deserialize; use serenity::utils::Colour; + use std::{fs, io::prelude::*}; #[derive(Deserialize)] struct EmbedProperties { @@ -268,7 +269,17 @@ fn embed(ctx: &mut Context, message: &Message, args: Args) -> CommandResult { url: Option, } - let input_embed: EmbedProperties = match toml::from_str(args.rest().trim()) { + if &args.rest().trim().to_string() == "help" { + let mut file = fs::File::open("./src/embed-docs.txt")?; + let mut help_string = String::new(); + file.read_to_string(&mut help_string)?; + + let _ = message.channel_id.say(&ctx.http, help_string); + + return Ok(()); + } + + let input_embed: EmbedProperties = match toml::from_str(&args.rest().trim()) { Ok(v) => v, Err(e) => { return Err(CommandError(format!("Deserialization error: {:?}", e)));