From 561b0e38b4cda6661425f76c8d707d58d0f12d09 Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Fri, 30 Jun 2017 11:12:31 +0200 Subject: Add a `quit` function` Fixes #70 --- src/client/context.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/client/context.rs b/src/client/context.rs index a65ffe3..eaae7b3 100644 --- a/src/client/context.rs +++ b/src/client/context.rs @@ -337,4 +337,15 @@ impl Context { let mut shard = self.shard.lock().unwrap(); shard.set_presence(game, status, afk) } + + /// Disconnects the shard from the websocket, essentially "quiting" it. + /// Note however that this will only exit the one which the `Context` was given. + /// If it's just one shard that's on, then serenity will stop any further actions + /// until [`Client::start`] and vice versa are called again. + /// + /// [`Client::start`]: ./struct.Client.html#method.start + pub fn quit(&self) -> Result<()> { + let mut shard = self.shard.lock().unwrap(); + shard.shutdown_clean() + } } -- cgit v1.2.3