Skip to content

Commit

Permalink
Fix breakage caused by CacheHttp -> Http
Browse files Browse the repository at this point in the history
* Use Http instead of CacheHttp

* Fix examples compiling

* Update MSRV lockfile

---------

Co-authored-by: GnomedDev <[email protected]>
  • Loading branch information
NotNorom and GnomedDev committed Jun 8, 2024
1 parent fdf55be commit 47bbbad
Show file tree
Hide file tree
Showing 9 changed files with 4,516 additions and 11 deletions.
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

0 comments on commit 47bbbad

Please sign in to comment.