forked from sorceress/rustcord
Add embed docs
This commit is contained in:
parent
52f329dbf6
commit
e6de3ed9f9
|
@ -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)"
|
||||
```
|
13
src/main.rs
13
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<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)));
|
||||
|
|
Loading…
Reference in New Issue