Skip to content

Commit

Permalink
feat: allow builder to set ActivityKind (#40)
Browse files Browse the repository at this point in the history
* feat: allow builder to set ActivityKind

* test: set kind field in ActivityBuilder test
  • Loading branch information
w-lfchen authored Sep 2, 2024
1 parent ba7e959 commit fbfd3f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions sdk/src/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,20 @@ impl ActivityBuilder {
}
self
}

/// Set the kind of this activity.
pub fn kind(mut self, kind: ActivityKind) -> Self {
match &mut self.inner.activity {
Some(activity) => activity.kind = kind,
None => {
self.inner.activity = Some(Activity {
kind,
..Default::default()
});
}
}
self
}
}

impl crate::Discord {
Expand Down Expand Up @@ -799,6 +813,7 @@ mod test {
join: Some("sekret".to_owned()),
..Default::default()
})
.kind(ActivityKind::Listening)
.into();

let cmd = crate::proto::Rpc {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/snapshots/discord_sdk__activity__test__serde.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ expression: cmd
"secrets": {
"join": "sekret"
},
"type": 0,
"type": 2,
"instance": false
}
}
Expand Down

0 comments on commit fbfd3f2

Please sign in to comment.