From 6dc458af54d47d1ac9eef93d516700d778908545 Mon Sep 17 00:00:00 2001 From: Skye Bleed Date: Sat, 7 Sep 2019 20:30:27 -0500 Subject: [PATCH] Added (useless) add command --- README.md | 6 ++++++ src/main.rs | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b51d2e4..fe53c12 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # Fishy! A discord bot made for Question of the Day in Oceanland! + +### Building +Assuming you have [Rust](https://rust-lang.org) installed, a simple `cargo run` should build fishy and its dependancies. + +### Usage +The command syntax is simply `fishy TOKEN`, where TOKEN is the token for the bot you're running. diff --git a/src/main.rs b/src/main.rs index 68eb0fa..88ed413 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use serenity::framework::standard::{ group!({ name: "general", options: {}, - commands: [hello], + commands: [hello, add], }); use std::env; @@ -71,9 +71,23 @@ fn main() { #[command] fn hello(ctx: &mut Context, msg: &Message) -> CommandResult { - println!("Executing HELLO..."); + println!("Executing command HELLO as \"{}\"", msg.content); msg.reply(ctx, "Hello!")?; Ok(()) } +#[command] +fn add(ctx: &mut Context, msg: &Message) -> CommandResult { + println!("Executing command ADD as \"{}\"", msg.content); + let split: Vec<&str> = msg.content.split(" ").collect(); + if split.len() < 3 { + msg.reply(ctx, "Please add a message!")?; + return Ok(()); + } + + let addition = &split[2..]; + msg.reply(ctx, format!("{}", addition.join(" ")))?; + + Ok(()) +}