summaryrefslogtreecommitdiff
path: root/07_sample_bot_structure/src/commands/owner.rs
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2020-08-04 20:31:39 +0200
committerDennis Kobert <dennis@kobert.dev>2020-08-04 20:31:39 +0200
commitf14ba9816bf32c7998a97a9cb55565a9e9a9bae5 (patch)
tree653e31f08018abd4e47870679469dd81662c5b55 /07_sample_bot_structure/src/commands/owner.rs
Initial commitHEADmaster
Diffstat (limited to '07_sample_bot_structure/src/commands/owner.rs')
-rw-r--r--07_sample_bot_structure/src/commands/owner.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/07_sample_bot_structure/src/commands/owner.rs b/07_sample_bot_structure/src/commands/owner.rs
new file mode 100644
index 0000000..cebb759
--- /dev/null
+++ b/07_sample_bot_structure/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(())
+}