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

feature request: converters with poise context #163

Open
sadorowo opened this issue May 5, 2023 · 3 comments
Open

feature request: converters with poise context #163

sadorowo opened this issue May 5, 2023 · 3 comments
Labels
potentially messy Potentially messy to implement, hinting at being a misguided feature request

Comments

@sadorowo
Copy link
Contributor

sadorowo commented May 5, 2023

Currently, we can only use serenity::Context in ArgumentConvert, PopArgument and SlashArgument, because all these traits are imported from serenity.
But what if we want to make a string-to-command converter? We are unable to use the ctx.framework() method in any way to get the command. The only solution would be to export the commands variable from other file, which is not a good solution.

Now the trait looks like this:

#[async_trait]
pub trait ArgumentConvert: Sized {
    type Err;

    async fn convert(
        ctx: &Context /* <- serenity::client::context::Context, NOT poise::Context<'_, Data, Error> */,
        guild_id: Option<GuildId>,
        channel_id: Option<ChannelId>,
        s: &str,
    ) -> Result<Self, Self::Err>;
}

How about creating a custom implementation, with Poise context support? It would be very helpful.

@kangalio
Copy link
Collaborator

kangalio commented May 5, 2023

I attempted something similar before, I think it could be made to work.

For motivation purposes and curiosity - what would you need a string-to-command converter for?

@sadorowo
Copy link
Contributor Author

sadorowo commented May 6, 2023

I attempted something similar before, I think it could be made to work.

For motivation purposes and curiosity - what would you need a string-to-command converter for?

for e.g. custom help command, you can simply pass Command as a parameter. I know you can pass String and then get command by its name/aliases/etc. but this would be simpler.

@kangalio
Copy link
Collaborator

kangalio commented May 6, 2023

Yeah, that's the only use I can think of either.

You can see my attempt from two years ago here in this todo card and this commit

@kangalio kangalio added the potentially messy Potentially messy to implement, hinting at being a misguided feature request label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potentially messy Potentially messy to implement, hinting at being a misguided feature request
Projects
None yet
Development

No branches or pull requests

2 participants