#discord #api #async

nightly automate

An asynchronous library to interact with Discord API

4 releases

✓ Uses Rust 2018 edition

0.1.3 Nov 29, 2019
0.1.2 Nov 20, 2019
0.1.1 Nov 15, 2019
0.1.0 Nov 15, 2019

#187 in Asynchronous

23 downloads per month

MIT license


Automate   Actions Status GitHub issues Crates.io Crates.io

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

DISCLAIMER: This crate is at its very early stage and does not have most functionalities a discord bot would need (no voice, and only channel manipulation operations). Please don't use this crate except for experimenting. The crate also only works in rust nightly.

Getting started

Automate is currently unstable and only works with Rust nightly. The minimum tested version and the one used in CI is nightly-2019-11-24. 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 under the [dependencies] section :

automate = "0.1.3"

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.


use automate::async_trait;
use automate::{Error, Discord, Listener, Session};
use automate::gateway::MessageCreateDispatch;
use automate::http::CreateMessage;
use std::env;

struct MessageListener;

impl Listener for MessageListener {
    async fn on_message_create(&mut self, session: &Session, message: &MessageCreateDispatch) -> Result<(), Error> {
        let message = &message.0;

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

            session.create_message(message.channel_id, CreateMessage {


fn main() -> Result<(), Error> {

    Discord::new(&env::var("DISCORD_API_TOKEN").expect("API token not found"))


Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Automate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~245K SLoC