Skip to content

Commit

Permalink
Fix breakage caused by small-fixed-array v2
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Jan 17, 2024
1 parent abb3202 commit f998bef
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 48 deletions.
71 changes: 32 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions examples/help_generation/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use ::serenity::small_fixed_array::FixedString;
use poise::{samples::HelpConfiguration, serenity_prelude as serenity};
use rand::Rng;

Expand Down Expand Up @@ -235,9 +236,10 @@ async fn food_react(
ctx: Context<'_>,
#[description = "Message to react to (enter a link or ID)"] msg: serenity::Message,
) -> Result<(), Error> {
let reaction = FOOD[rand::thread_rng().gen_range(0..FOOD.len())].to_string();
msg.react(ctx, serenity::ReactionType::Unicode(reaction.into()))
.await?;
let reaction = FOOD[rand::thread_rng().gen_range(0..FOOD.len())];
let reaction = serenity::ReactionType::Unicode(FixedString::from_str_trunc(reaction));

msg.react(ctx, reaction).await?;
ctx.say("Reacted!").await?;
Ok(())
}
Expand All @@ -257,9 +259,10 @@ async fn fruit_react(
ctx: Context<'_>,
#[description = "Message to react to (enter a link or ID)"] msg: serenity::Message,
) -> Result<(), Error> {
let reaction = FRUIT[rand::thread_rng().gen_range(0..FRUIT.len())].to_string();
msg.react(ctx, serenity::ReactionType::Unicode(reaction.into()))
.await?;
let reaction = FRUIT[rand::thread_rng().gen_range(0..FRUIT.len())];
let reaction = serenity::ReactionType::Unicode(FixedString::from_str_trunc(reaction));

msg.react(ctx, reaction).await?;
ctx.say("Reacted!").await?;
Ok(())
}
Expand All @@ -275,9 +278,10 @@ async fn vegetable_react(
ctx: Context<'_>,
#[description = "Message to react to (enter a link or ID)"] msg: serenity::Message,
) -> Result<(), Error> {
let reaction = VEGETABLES[rand::thread_rng().gen_range(0..VEGETABLES.len())].to_string();
msg.react(ctx, serenity::ReactionType::Unicode(reaction.into()))
.await?;
let reaction = VEGETABLES[rand::thread_rng().gen_range(0..VEGETABLES.len())];
let reaction = serenity::ReactionType::Unicode(FixedString::from_str_trunc(reaction));

msg.react(ctx, reaction).await?;
ctx.say("Reacted!").await?;
Ok(())
}
Expand Down

0 comments on commit f998bef

Please sign in to comment.