Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update discord_rpc.rs #19

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions muzik-offline/src-tauri/src/socials/discord_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ impl DiscordRpc {
}

pub fn set_activity(&mut self, song_name: String, state: String, large_image_key: String) -> Result<(), Box<dyn std::error::Error>> {
//if not connected, attempt to connect
if !self.is_connected {
self.connect()?;
}

if self.allowed_to_connect && self.is_connected {
let activity = activity::Activity::new()
.state(&state)
Expand All @@ -60,6 +65,11 @@ impl DiscordRpc {
}

pub fn clear_activity(&mut self) -> Result<(), Box<dyn std::error::Error>> {
//if not connected, attempt to connect
if !self.is_connected {
self.connect()?;
}

if self.allowed_to_connect && self.is_connected {
self.client.clear_activity()?;
Ok(())
Expand Down