Giter Club home page Giter Club logo

Comments (7)

LilJess13 avatar LilJess13 commented on August 24, 2024

This same error also appears when trying to add a user_command in a cog. It appeared for me on a cog reload

from pycord.

LilJess13 avatar LilJess13 commented on August 24, 2024

This error appears to always happen when using reload_extension. Not only does it give this error, it also disables all prefixed commands in cogs. Slash commands continue to work and the prefixed commands work after the bot is restarted.

from pycord.

yagomichalak avatar yagomichalak commented on August 24, 2024

In my case, all commands seem to work just fine, but the simple fact of having a slash/user/message command in a cog, makes this error to appear whenever one uses the cog.get_commands()

from pycord.

BobDotCom avatar BobDotCom commented on August 24, 2024

This error appears to always happen when using reload_extension. Not only does it give this error, it also disables all prefixed commands in cogs. Slash commands continue to work and the prefixed commands work after the bot is restarted.

this is likely because both get_command and reload_extension access all_commands which appears to be the issue

from pycord.

BobDotCom avatar BobDotCom commented on August 24, 2024

could you add more to your minimal reproducable code? This isn't descriptive enough for me to test

from pycord.

LilJess13 avatar LilJess13 commented on August 24, 2024

could you add more to your minimal reproducable code? This isn't descriptive enough for me to test

This took me a while to figure out how to reproduce, but i got it.

Main file:

@bot.command(name = 'reload')
async def _reload(ctx):
    bot.reload_extension('cogs.CogTest')
    await ctx.send("reloaded cog")

for filename in os.listdir('./cogs'):
  if filename.endswith('.py'):
    bot.load_extension(f'cogs.{filename[:-3]}')

Cog:

from discord.ext import commands
from discord.app import commands as app
from discord import Option

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

    @app.slash_command(description = "I describe", guild_ids = [250507134876254208])
    async def reply(self, ctx):
        await ctx.respond(f"Hi")

    @commands.command()
    async def test(self, ctx):
        await ctx.send("test")

The order that the commands are in inside of the cog is important. The error only occurs when a prefixed command is after a slash command.

from pycord.

Middledot avatar Middledot commented on August 24, 2024

I have implemented a fix for this on the restructure branch that should work, let me know if there's something else wrong with it in your use case.

from pycord.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.