Open sarahkittyy opened 7 months ago
It's possible your Cargo.toml contains a different serenity version than the one poise uses, which means the two mismatching serenity Context types only mismatch because they're of two different versions.. Poise 0.6 needs Serenity 0.12. Is that the case in your Cargo.toml?
There is no serenity in my Cargo.toml. I am using the one that comes in the poise crate. The types are the same. Rust does not have a blanket impl AsRef<T> for &T
. To solve this I had to implement execute_model_generic
myself.
Please attach your Cargo.lock file, so we can see if you have duplicate dependencies.
Here. Poise 0.6.1 and Serenity 0.12.1. Cargo.lock.txt
The problem is not duplicate dependencies. The types are the same. AsRef<poise::serenity_prelude::Context>
is NOT implemented for poise::serenity_prelude::Context
. This is a known quirk of the rust language.
See https://doc.rust-lang.org/std/convert/trait.AsRef.html#reflexivity Also see this minimal example
To fix this I copied the existing but private execute_modal_generic
here into my own code.
I'm not a Rust pro but maybe this should be impl Into<>
or Deref<>
or Borrow<>
instead? Or maybe impl CacheHttp
.
It shouldn't be AsRef in the first place, it should just be &serenity::Context
, I'll make that change now. Anyway, for now can't you just pass &serenity::Context?
No! You cannot pass &serenity::Context
to a parameter of type impl AsRef<serenity::Context>
because as per my last comments, &T
does not implement the trait AsRef<T>
. You would think it would, but it doesn't. See https://doc.rust-lang.org/std/convert/trait.AsRef.html#reflexivity.
Changing execute_modal_on_component_interaction
's first argument to &serenity::Context
instead of impl AsRef<serenity::Context>
will fix this issue. Thanks ^^
That is so weird.
What is this error? I am trying to use poise::execute_modal_on_component_interaction.
Here is my function:
And my error is:
What is happening? I know in general there is no blanket
impl AsRef<T> for &T
in Rust because of some sort of conflict, but what do I do in this case? I feel like I am missing something obvious.