#making eval command

1 messages · Page 1 of 1 (latest)

tired elk
#

how do i fix this error?

the code:

from discord import DiscordException
from discord.ext import commands, bridge

class Owner(commands.Cog):
    def __init__(self, bot: bridge.Bot):
        self.bot = bot

    @bridge.bridge_command(name="eval", description="evaluates python codes")
    @commands.is_owner()
    async def eval_command(self, ctx: bridge.BridgeContext, *, code: str):
        await ctx.defer()
        try:
            result = eval(code)
            await ctx.respond(f'\`\`\`py\n{result}\`\`\`')
        except Exception as error:
            await ctx.respond(f'\`\`\`py\n{error}\`\`\`')

    @eval_command.error
    async def on_error(ctx: bridge.BridgeContext, error: DiscordException):
        if isinstance(error, commands.NotOwner):
            await ctx.respond("You cannot use this command.")
        else:
            raise error

def setup(bot):
    bot.add_cog(Owner(bot))```
twilit plover
#

you're missing self