pub struct Discord { /* private fields */ }
Implementations§
Source§impl Discord
impl Discord
Sourcepub async fn update_activity(
&self,
activity: impl Into<ActivityArgs>,
) -> Result<Option<Activity>, Error>
pub async fn update_activity( &self, activity: impl Into<ActivityArgs>, ) -> Result<Option<Activity>, Error>
Sourcepub async fn invite_user(
&self,
user_id: UserId,
message: impl Into<String>,
kind: ActivityActionKind,
) -> Result<(), Error>
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.
Sourcepub async fn accept_invite(
&self,
invite: &impl AsRef<ActivityInvite>,
) -> Result<(), Error>
pub async fn accept_invite( &self, invite: &impl AsRef<ActivityInvite>, ) -> Result<(), Error>
Accepts the invite to another user’s activity.
Sourcepub async fn send_join_request_reply(
&self,
user_id: UserId,
reply: impl Into<JoinRequestReply>,
) -> Result<(), Error>
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.
Source§impl Discord
impl Discord
Sourcepub async fn set_overlay_visibility(
&self,
visibility: Visibility,
) -> Result<(), Error>
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.
Sourcepub async fn open_activity_invite(
&self,
action: InviteAction,
) -> Result<(), Error>
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.
Sourcepub async fn open_guild_invite(
&self,
code: impl AsRef<str>,
) -> Result<(), Error>
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.
Source§impl Discord
impl Discord
Sourcepub async fn get_relationships(&self) -> Result<Vec<Relationship>, Error>
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
impl Discord
Sourcepub fn new(
app: impl Into<DiscordApp>,
subscriptions: Subscriptions,
handler: Box<dyn DiscordHandler>,
) -> Result<Self, Error>
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
Sourcepub async fn disconnect(self)
pub async fn disconnect(self)
Disconnects from Discord, shutting down the tasks that have been created to handle sending and receiving messages from it.