[−][src]Struct automate::Discord
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]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,