aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-06-30 11:12:31 +0200
committeracdenisSK <[email protected]>2017-06-30 11:12:31 +0200
commit561b0e38b4cda6661425f76c8d707d58d0f12d09 (patch)
tree4dc13d5beef1615183e72ea3df32e9454722ac8f /src
parentAlso update examples (diff)
downloadserenity-561b0e38b4cda6661425f76c8d707d58d0f12d09.tar.xz
serenity-561b0e38b4cda6661425f76c8d707d58d0f12d09.zip
Add a `quit` function`
Fixes #70
Diffstat (limited to 'src')
-rw-r--r--src/client/context.rs11
1 files changed, 11 insertions, 0 deletions
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()
+ }
}