#Converter

1 messages · Page 1 of 1 (latest)

vague hatch
#

I don’t think that is possible

tranquil hollow
#

add a check for it

#

or just add a function you call to ensure that

olive crater
#

It's not possible to enforce it in the client
But it's literally just an if statement in the body

craggy pasture
#

How about a decorator for implementation?

olive crater
#

not sure what you mean by that

craggy pasture
olive crater
#

No

craggy pasture
#

In fact, I'm trying to implement it through this kind of logic.

class ValidRoleConverter(lightbulb.converters.RoleConverter):
    async def convert(self, ctx: lightbulb.Context, argument: str) -> hikari.Role:
        role = await super().convert(ctx, argument)
        if role.is_everyone:
            raise ValueError('Use of the @everyone role is prohibited')
        return role

and

@lightbulb.option('role_1', 'Select role 1', ValidRoleConverter, required=True)
@lightbulb.option('role_2', 'Select role 2', ValidRoleConverter, required=True)

But I'm doing something wrong because it's not working.

craggy pasture
olive crater
#

the presence of the options upon check invocation is not guaranteed

#

so if something changes in lightbulb internals that breaks it then on your head be it

craggy pasture
#

OK, how best to do this given that this logic is needed for about 8-12 invoke command

olive crater
#

you can write your own decorator and place it at the bottom of the stack
because when it is invoked the args are guaranteed to be populated