[][src]Struct automate::Discord

pub struct Discord { /* fields omitted */ }

The struct used to register listeners, setup configuration and establish connection with Discord.

Example

use automate::Discord;

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

Methods

impl Discord[src]

pub fn new(token: &str) -> Discord[src]

Creates an instance of this struct with the provided token. The token can be generated on Discord's developers portal

pub fn with_listener(self, listener: Box<dyn Listener + Send>) -> Self[src]

Registers an event listener

pub async fn connect(self) -> Result<!, Error>[src]

Asynchronous function setup the connection with Discord. Will block forever unless the bot crashes.

pub fn connect_blocking(self) -> Result<!, Error>[src]

Non asynchronous equivalent for the connect function to setup the connection with discord. Creates a tokio runtime.

Will block forever unless the bot crashes.

pub fn connect_detached(self) -> JoinHandle<Result<!, Error>>[src]

Non asynchronous equivalent for the connect function to setup the connection with discord. This function establishes the connection and runs the event loop in a separate thread whose JoinHandle is returned.

Auto Trait Implementations

impl Send for Discord

impl Sync for Discord

impl Unpin for Discord

impl !UnwindSafe for Discord

impl !RefUnwindSafe for Discord

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,