#Commands in a cog not found

1 messages · Page 1 of 1 (latest)

mossy peak
#

I got this error while trying to execute a command in a cog:

main.py

class SchoolBot(commands.Bot):
    def __init__(self):
        super().__init__(
            command_prefix='!',
            intents=Intents.all(),
            sync_command=True,
            application_id=APPID
        )

    async def setup_hook(self):
        await self.load_extension("Cogs.Signup")
        await bot.tree.sync(guild=Object())

    async def on_ready(self):
        print("Login Complete!")
        print(self.user.name)
        print(self.user.id)
        print("===============")
        game = Game("Taking school classes")
        await self.change_presence(status=Status.online, activity=game)

Cogs/Signup.py:

class Application(Modal):
    def __init__(self):
        super.__init__("학교 정보 입력")
        self.input = InputText(style=InputTextStyle.name, label="학교 이름", required=True)
        self.add_item(self.input)

    async def callback(self, interaction: Interaction) -> None:
        spread.addRow([interaction.user.id, self.input.value, 0, 0])

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

    @commands.command()
    async def register(self, ctx):
        btn = Button(label='학교 등록', style=ButtonStyle.primary)

        async def showEntry(self, interaction: Interaction) -> None:
            app = Application()
            interaction.response.send_modal(app)

        btn.callback = showEntry
        view = View()
        view.add_item(btn)
        await ctx.send('학교 등록을 위해 버튼 선택', view=view)

async def setup(bot: commands.Bot) -> None:
    await bot.add_cog(Signup(bot))

Specific traceback:

Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "register" is not found

Additionally, I would be really thankful for pointing out other mistakes I made.

mortal barn
mossy peak
#

no, it's definitely pycord

mortal barn
#

Why is the setup func in async?

mossy peak
#

I thought add_cog is a coroutine so

#

I used async

mortal barn
#

Also you use interaction and commands.Bot

mossy peak
#

I, uh, just moved to pycord and there was no error so I kept using it

mortal barn
#

Can you show the pip list?

mossy peak
#

before writing that code

mortal barn
#

Also any other stuff?

#

like discord

mossy peak
#

well I uninstalled other discord-related libs

#

Ill just show you the pip list

calm shardBOT
#

Here's the slash basic example.

mossy peak
mortal barn
#

How can you use ctx.send with an Interaction?

mossy peak
#

ah right

#

should use interaction not ctx

mortal barn
#

ctx.respond for slash_command

mossy peak
#

oh ok

mossy peak
#

Well setup_hook does not seem to work fsr

#

LMAO I was confusing pycord code with discord.py, it worked my bad