Skip to content

Commit

Permalink
Fix examples and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Jan 21, 2024
1 parent 53a4082 commit aa3b5cf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 3 additions & 1 deletion examples/basic_structure/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ pub async fn vote(
ctx: Context<'_>,
#[description = "What to vote for"] choice: String,
) -> Result<(), Error> {
let data = ctx.data();

// Lock the Mutex in a block {} so the Mutex isn't locked across an await point
let num_votes = {
let mut hash_map = ctx.data().votes.lock().unwrap();
let mut hash_map = data.votes.lock().unwrap();
let num_votes = hash_map.entry(choice.clone()).or_default();
*num_votes += 1;
*num_votes
Expand Down
4 changes: 2 additions & 2 deletions src/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async fn execute_modal_generic<
/// 1. sends the modal via [`Modal::create()`]
/// 2. waits for the user to submit via [`serenity::ModalInteractionCollector`]
/// 3. acknowledges the submitted data so that Discord closes the pop-up for the user
/// 4. parses the submitted data via [`Modal::parse()`], wrapping errors in [`serenity::Error::Other`]
/// 4. parses the submitted data via [`Modal::parse()`]
///
/// If you need more specialized behavior, you can copy paste the implementation of this function
/// and adjust to your needs. The code of this function is just a starting point.
Expand Down Expand Up @@ -113,7 +113,7 @@ pub async fn execute_modal<U: Send + Sync + 'static, E, M: Modal>(
/// 1. sends the modal via [`Modal::create()`] as a mci interaction response
/// 2. waits for the user to submit via [`serenity::ModalInteractionCollector`]
/// 3. acknowledges the submitted data so that Discord closes the pop-up for the user
/// 4. parses the submitted data via [`Modal::parse()`], wrapping errors in [`serenity::Error::Other`]
/// 4. parses the submitted data via [`Modal::parse()`]
///
/// If you need more specialized behavior, you can copy paste the implementation of this function
/// and adjust to your needs. The code of this function is just a starting point.
Expand Down
9 changes: 1 addition & 8 deletions src/prefix_argument/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,7 @@ to use this macro directly.
```rust,no_run
# #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> {
# use poise::serenity_prelude as serenity;
# let ctx = serenity::Context {
# data: Default::default(),
# shard: todo!(),
# shard_id: todo!(),
# http: std::sync::Arc::new(::serenity::http::Http::new("example")),
# #[cfg(feature = "cache")]
# cache: Default::default(),
# };
# let ctx = todo!();
# let msg = serenity::CustomMessage::new().build();
assert_eq!(
Expand Down

0 comments on commit aa3b5cf

Please sign in to comment.