Struct Discord

Source
pub struct Discord { /* private fields */ }

Implementations§

Source§

impl Discord

Source

pub async fn update_activity( &self, activity: impl Into<ActivityArgs>, ) -> Result<Option<Activity>, Error>

Sets the current User's presence in Discord to a new activity.

§Errors

This has a rate limit of 5 updates per 20 seconds.

API docs

Source

pub async fn invite_user( &self, user_id: UserId, message: impl Into<String>, kind: ActivityActionKind, ) -> Result<(), Error>

Invites the specified User to join the current user’s game.

§Errors

The current User must have their presence updated with all of the required fields otherwise this call will fail.

API docs

Source

pub async fn accept_invite( &self, invite: &impl AsRef<ActivityInvite>, ) -> Result<(), Error>

Accepts the invite to another user’s activity.

API docs

Source

pub async fn clear_activity(&self) -> Result<Option<Activity>, Error>

Clears the rich presence for the logged in User.

API docs

Source

pub async fn send_join_request_reply( &self, user_id: UserId, reply: impl Into<JoinRequestReply>, ) -> Result<(), Error>

Sends a reply to an Ask to Join request.

API docs

Source§

impl Discord

Source

pub async fn set_overlay_visibility( &self, visibility: Visibility, ) -> Result<(), Error>

Opens or closes the overlay. If the overlay is not enabled this will instead focus the Discord app itself.

API docs

Source

pub async fn open_activity_invite( &self, action: InviteAction, ) -> Result<(), Error>

Opens the overlay modal for sending game invitations to users, channels, and servers.

§Errors

If you do not have a valid activity with all the required fields, this call will error. See Activity Action Field Requirements for the fields required to have join and spectate invites function properly.

API docs

Source

pub async fn open_guild_invite( &self, code: impl AsRef<str>, ) -> Result<(), Error>

Opens the overlay modal for joining a Discord guild, given its invite code. Unlike the normal SDK, this method automatically parses the code from the provided string so you don’t need to do it yourself.

Note that just because the result might be Result::Ok doesn’t necessarily mean the user accepted the invite.

API docs

Source

pub async fn open_voice_settings(&self) -> Result<(), Error>

Opens the overlay widget for voice settings for the currently connected application.

API docs

Source§

impl Discord

Source

pub async fn get_relationships(&self) -> Result<Vec<Relationship>, Error>

The regular Game SDK does not really expose this functionality directly, but rather exposed via the “on refresh” event as described in the docs.

Basically, this method should be used to bootstrap the relationships for the current user, with updates to that list coming via the RelationshipUpdate event

Source§

impl Discord

Source

pub fn new( app: impl Into<DiscordApp>, subscriptions: Subscriptions, handler: Box<dyn DiscordHandler>, ) -> Result<Self, Error>

Creates a new Discord connection for the specified application, providing a DiscordHandler which can handle events as they arrive from Discord

Source

pub async fn disconnect(self)

Disconnects from Discord, shutting down the tasks that have been created to handle sending and receiving messages from it.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,