Add embed docs

This commit is contained in:
Agatha Rose 2020-06-11 19:04:32 +03:00
parent 52f329dbf6
commit e6de3ed9f9
No known key found for this signature in database
GPG Key ID: 3F9F2317B3D5C3AC
2 changed files with 30 additions and 1 deletions

18
src/embed-docs.txt Normal file
View File

@ -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)"
```

View File

@ -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<String>,
}
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)));