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

Fix integer parsing on large integers with small types #283

Closed
Closed
Show file tree
Hide file tree
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
2,251 changes: 2,251 additions & 0 deletions .github/Cargo-msrv.lock

Large diffs are not rendered by default.

2,251 changes: 2,251 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/event_handler/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async fn event_handler(
let old_mentions = data.poise_mentions.fetch_add(1, Ordering::SeqCst);
new_message
.reply(
ctx,
&ctx.http,
format!("Poise has been mentioned {} times", old_mentions + 1),
)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion examples/feature_showcase/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub async fn delete(
#[description = "Message to be deleted"] msg: serenity::Message,
reason: Option<String>,
) -> Result<(), Error> {
msg.delete(ctx, reason.as_deref()).await?;
msg.delete(ctx.http(), reason.as_deref()).await?;
Ok(())
}

Expand Down
6 changes: 3 additions & 3 deletions examples/help_generation/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ async fn food_react(
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?;
msg.react(ctx.http(), reaction).await?;
ctx.say("Reacted!").await?;
Ok(())
}
Expand All @@ -262,7 +262,7 @@ async fn fruit_react(
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?;
msg.react(ctx.http(), reaction).await?;
ctx.say("Reacted!").await?;
Ok(())
}
Expand All @@ -281,7 +281,7 @@ async fn vegetable_react(
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?;
msg.react(ctx.http(), reaction).await?;
ctx.say("Reacted!").await?;
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions examples/manual_dispatch/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ struct Handler {
}
#[serenity::async_trait]
impl serenity::EventHandler for Handler {
async fn message(&self, serenity_context: &serenity::Context, new_message: &serenity::Message) {
async fn message(&self, serenity_context: serenity::Context, new_message: serenity::Message) {
// FrameworkContext contains all data that poise::Framework usually manages
let shard_manager = (*self.shard_manager.lock().unwrap()).clone().unwrap();
let framework_data = poise::FrameworkContext {
serenity_context,
serenity_context: &serenity_context,
options: &self.options,
shard_manager: &shard_manager,
};
Expand All @@ -35,7 +35,7 @@ impl serenity::EventHandler for Handler {

let res = poise::dispatch_message(
framework_data,
new_message,
&new_message,
trigger,
&invocation_data,
&mut parent_commands,
Expand Down
5 changes: 4 additions & 1 deletion src/dispatch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ pub async fn dispatch_event<U: Send + Sync + 'static, E>(
.unwrap()
.process_message_delete(*deleted_message_id);
if let Some(bot_response) = bot_response {
if let Err(e) = bot_response.delete(framework.serenity_context, None).await {
if let Err(e) = bot_response
.delete(&framework.serenity_context.http, None)
.await
{
tracing::warn!("failed to delete bot response: {}", e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/reply/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl ReplyHandle<'_> {
ctx: crate::Context<'_, U, E>,
) -> Result<(), serenity::Error> {
match &self.0 {
ReplyHandleInner::Prefix(msg) => msg.delete(ctx.serenity_context(), None).await?,
ReplyHandleInner::Prefix(msg) => msg.delete(ctx.http(), None).await?,
ReplyHandleInner::Application {
http: _,
interaction,
Expand Down
2 changes: 1 addition & 1 deletion src/reply/send_reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub async fn send_prefix_reply<'a, U: Send + Sync + 'static, E>(
let new_response = ctx
.msg
.channel_id
.send_message(ctx.serenity_context(), builder.to_prefix(ctx.msg.into()))
.send_message(ctx.http(), builder.to_prefix(ctx.msg.into()))
.await?;
// We don't check ctx.command.reuse_response because we need to store bot responses for
// track_deletion too
Expand Down
5 changes: 3 additions & 2 deletions src/slash_argument/slash_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ macro_rules! impl_for_integer {
match *value {
serenity::ResolvedValue::Integer(x) => x
.try_into()
.map_err(|_| SlashArgError::CommandStructureMismatch {
description: "received out of bounds integer",
.map_err(|e| SlashArgError::Parse {
error: Box::new(e),
input: x.to_string(),
}),
_ => Err(SlashArgError::CommandStructureMismatch {
description: "expected integer",
Expand Down
Loading