#discord #api #async

nightly automate

An asynchronous library to interact with Discord API and make bots

10 unstable releases (3 breaking)

0.4.0 Oct 11, 2020
0.3.1 Apr 25, 2020
0.3.0 Mar 27, 2020
0.2.1 Feb 29, 2020
0.1.3 Nov 29, 2019

#31 in #discord

43 downloads per month

MIT license


Automate   GitHub Workflow Status Crates.io Discord Documentation License

Automate is a low level and asynchronous rust library for interacting with the Discord API.

Getting started

Automate currently only works with Rust nightly starting from 1.45. The usually tested version and the one used in CI is nightly-2020-08-03, you can use more recent versions but please swich back to this version if you get a compile error. Refer to rust edition guide to learn how to switch to rust nightly.

In order to use Automate in your project, add the following line to your Cargo.toml :

automate = "0.4.0"

You can then write the following in your main.rs. This simple example will respond Hello ! to any user posting a message in any channel while ignoring messages from bots. In order for this example to work, you need to define the DISCORD_API_TOKEN environment variable. You can create a bot and generate a token on Discord's developers portal.

extern crate automate;

use automate::{Error, Configuration, Context, Automate};
use automate::gateway::MessageCreateDispatch;
use automate::http::CreateMessage;

async fn say_hello(ctx: &mut Context, data: &MessageCreateDispatch) -> Result<(), Error> {
    let message = &data.0;

    if message.author.id != ctx.bot.id {
        let content = Some(format!("Hello {}!", message.author.username));

        ctx.create_message(message.channel_id, CreateMessage {


fn main() {
    let config = Configuration::from_env("DISCORD_API_TOKEN")


For examples with more details, see in the examples folder. You can also refer to the documentation.

Upcoming features

While mature enough to make text bots, Automate is still missing some important features which will be implemented soon such as :

  • Caching system: necessary to avoid making API calls each time you need information about a member or a guild. You can still implement it manually, see the levels example.
  • Voice: it is possible to interact with members in voice channels (kicking, muting, deafening them...) but it is not possible to make the bot join a channel and receive or send sound.
  • More examples: not a feature but necessary to properly show how the library works, feel free to make pull request if you want to submit one :)


Any kind of contribution is welcome, from issues to pull requests. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update documentation as appropriate.

If you need support, want to report a bug or contribute, you can join the library's discord server using this invite https://discord.gg/invite/PGGYXy2


Licensed under the MIT license.


~248K SLoC