#help with making flags

1 messages · Page 1 of 1 (latest)

spare hatch
#

i tried to make this --await flag for my eval command but the code not running

class EvalFlags(commands.FlagConverter, delimiter="=", prefix="--"):
        awaited: bool = commands.flag(name='await', default=False)

@bridge.bridge_command(name="eval", description="evaluates python codes")
@commands.is_owner()
async def eval_command(self, ctx: bridge.BridgeContext, *, code: str = '', flags: EvalFlags):
    await ctx.defer()
    if not code:
        await ctx.respond('provide code to evalauate')
        return
        
    env = {
       'ctx': ctx,
       'bot': self.bot
    }

    try:
        if flags.awaited:
            async def wrapper():
                 return await eval(code, env)
            result = await wrapper()
       else:
            result = eval(code, env)```
slate prism
spare hatch