Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Hellyer committed Oct 18, 2016
0 parents commit 8fc8c81
Show file tree
Hide file tree
Showing 101 changed files with 11,777 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target/

Cargo.lock
69 changes: 69 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[package]
authors = ["Austin Hellyer <[email protected]>"]
build = "build.rs"
description = "Ergonomic and high-level Rust library for the Discord API."
documentation = "http://docs.austinhellyer.me/serenity"
keywords = ["discord", "api"]
license = "ISC"
name = "serenity"
readme = "README.md"
repository = "https://github.com/zeyla/serenity.rs"
version = "0.1.0"

[dependencies]
base64 = "0.2"
bitflags = "0.7"
byteorder = "0.5"
flate2 = "0.2"
hyper = "0.9"
lazy_static = "0.2"
log = "0.3"
serde_json = "0.8"
time = "0.1"
websocket = "0.17"

[dependencies.cookie]
default-features = false
version = "0.2"

[dependencies.multipart]
default-features = false
features = ["client", "hyper"]
version = "0.8"

[build-dependencies]
yaml-rust = "0.3"

[features]
default = []
debug = []

[[bin]]
doc = false
name = "example-01"
path = "./examples/01_basic_ping_bot.rs"

[[bin]]
doc = false
name = "example-02"
path = "./examples/02_transparent_guild_sharding.rs"

[[bin]]
doc = false
name = "example-03"
path = "./examples/03_struct_utilities.rs"

[[bin]]
doc = false
name = "example-04"
path = "./examples/04_message_builder.rs"

[[bin]]
doc = false
name = "example-05"
path = "./examples/05_user_login.rs"

[[bin]]
doc = false
name = "example-06"
path = "./examples/06_command_framework.rs"
15 changes: 15 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License (ISC)

Copyright (c) 2016, Austin Hellyer <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# serenity.rs

Serenity is an ergonomic and high-level Rust library for the Discord API.

View the [examples] on how to make and structure a bot.

Serenity supports both bot and user login via the use of [`Client::login_bot`]
and [`Client::login_user`].

You may also check your tokens prior to login via the use of
[`validate_token`].

Once logged in, you may add handlers to your client to dispatch [`Event`]s,
such as [`Client::on_message`]. This will cause your handler to be called
when a [`Event::MessageCreate`] is received. Each handler is given a
[`Context`], giving information about the event. See the
[client's module-level documentation].

The [`Connection`] is transparently handled by the library, removing
unnecessary complexity. Sharded connections are automatically handled for
you. See the [Connection's documentation][`Connection`] for more
information.

A [`State`] is also provided for you. This will be updated automatically for
you as data is received from the Discord API via events. When calling a
method on a [`Context`], the state will first be searched for relevant data
to avoid unnecessary HTTP requests to the Discord API. For more information,
see the [state's module-level documentation][state docs].

Note that - although this documentation will try to be as up-to-date and
accurate as possible - Discord hosts [official documentation][docs]. If you
need to be sure that some information piece is accurate, refer to their
docs.

# Dependencies

Serenity requires the following dependencies:

- openssl

# Example Bot

A basic ping-pong bot looks like:

```rust,ignore
extern crate serenity;
use serenity::Client;
fn main() {
// Login with a bot token from the environment
let client = Client::login_bot(env::var("DISCORD_TOKEN").expect("token"));
client.with_framework(|c| c
.prefix("~") // set the bot's prefix to '~'
.on("ping", |_context, message| drop(message.reply("Pong!"))));
let _ = client.start(); // start listening for events by starting a connection
}
```

[`Client::login_bot`]: client/struct.Client.html#method.login_bot
[`Client::login_user`]: client/struct.Client.html#method.login_user
[`Client::on_message`]: client/struct.Client.html#method.on_message
[`validate_token`]: client/fn.validate_token.html
[`Connection`]: client/struct.Connection.html
[`Context`]: client/struct.Context.html
[`Event`]: model/enum.Event.html
[`Event::MessageCreate`]: model/enum.Event.html#MessageCreate.v
[`State`]: ext/state/struct.State.html
[client's module-level documentation]: client/index.html
[docs]: https://discordapp.com/developers/docs/intro
[examples]: https://github.com/zeyla/serenity.rs/tree/master/examples
[state docs]: ext/state/index.html
Loading

0 comments on commit 8fc8c81

Please sign in to comment.