summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/math.rs18
-rw-r--r--src/commands/meta.rs13
-rw-r--r--src/commands/mod.rs3
-rw-r--r--src/commands/owner.rs25
4 files changed, 59 insertions, 0 deletions
diff --git a/src/commands/math.rs b/src/commands/math.rs
new file mode 100644
index 0000000..ce7beed
--- /dev/null
+++ b/src/commands/math.rs
@@ -0,0 +1,18 @@
+use serenity::prelude::*;
+use serenity::model::prelude::*;
+use serenity::framework::standard::{
+ Args, CommandResult,
+ macros::command,
+};
+
+#[command]
+pub fn multiply(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult {
+ let one = args.single::<f64>().unwrap();
+ let two = args.single::<f64>().unwrap();
+
+ let product = one * two;
+
+ let _ = msg.channel_id.say(&ctx.http, product);
+
+ Ok(())
+}
diff --git a/src/commands/meta.rs b/src/commands/meta.rs
new file mode 100644
index 0000000..d58af10
--- /dev/null
+++ b/src/commands/meta.rs
@@ -0,0 +1,13 @@
+use serenity::prelude::*;
+use serenity::model::prelude::*;
+use serenity::framework::standard::{
+ CommandResult,
+ macros::command,
+};
+
+#[command]
+fn ping(ctx: &mut Context, msg: &Message) -> CommandResult {
+ let _ = msg.channel_id.say(&ctx.http, "Pong!");
+
+ Ok(())
+}
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
new file mode 100644
index 0000000..9c5dfaa
--- /dev/null
+++ b/src/commands/mod.rs
@@ -0,0 +1,3 @@
+pub mod math;
+pub mod meta;
+pub mod owner;
diff --git a/src/commands/owner.rs b/src/commands/owner.rs
new file mode 100644
index 0000000..cebb759
--- /dev/null
+++ b/src/commands/owner.rs
@@ -0,0 +1,25 @@
+use crate::ShardManagerContainer;
+use serenity::prelude::*;
+use serenity::model::prelude::*;
+use serenity::framework::standard::{
+ CommandResult,
+ macros::command,
+};
+
+#[command]
+#[owners_only]
+fn quit(ctx: &mut Context, msg: &Message) -> CommandResult {
+ let data = ctx.data.read();
+
+ if let Some(manager) = data.get::<ShardManagerContainer>() {
+ manager.lock().shutdown_all();
+ } else {
+ let _ = msg.reply(&ctx, "There was a problem getting the shard manager");
+
+ return Ok(());
+ }
+
+ let _ = msg.reply(&ctx, "Shutting down!");
+
+ Ok(())
+}