#Really strange

1 messages · Page 1 of 1 (latest)

midnight frigate
#
  File "/home/container/Slashs/Fun/handman.py", line 23, in hangman
    word_category = random.choice(list(self.words.keys()))
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Fun_Setup' object has no attribute 'words'

from data import *

class Fun_Hangman(commands.Cog):
    def __init__(self, bot):
        self.bot: Lumabot = bot
        self.words = {
            "animals": ["cat", "dog", "elephant", "lion", "tiger", "monkey"],
            "fruits": ["apple", "banana", "orange", "grape", "strawberry"],
            "countries": ["usa", "uk", "china", "india", "japan", "russia"]
        }

    @subcommand(f"{translator.fun.name}")
    @commands.slash_command()
    async def hangman(self, ctx: discord.ApplicationContext):
        word_category = random.choice(list(self.words.keys()))
        return
#

It told me about another class that i dont even have in the file and that i dont even have imported

midnight frigate
#

Hello @broken dragon, I find another bug with py-cord multicog
When we use the decorator for the fonction, it will also change the self to the one where the cog where the group has been definied, causing an attribute error.
Here a reproductible code for you :

class Bot_Test(commands.Cog):
    def __init__(self, bot):
        self.bot: Lumabot = bot
        self.test_multicog = "Test"

    @subcommand(f"{translator.bot.name}")
    @commands.slash_command()
    async def test(self, ctx: discord.ApplicationContext):
        print(self.test_multicog)
        await ctx.respond(content="test")

def setup(bot):
    bot.add_cog(Bot_Test(bot))


class Bot_Setup(commands.Cog):
    def __init__(self, bot):
        self.bot: Lumabot = bot
        self.test_multicog = "wrong test"
        
    botgroup = discord.SlashCommandGroup(name=translator.bot.name, description=translator.bot.description, guild_only=True)

def setup(bot):
    bot.add_cog(Bot_Setup(bot))
#

it will print (wrong test) when using /bot test

broken dragon
#

I see

#

I remember setting the subcommand's cog to the one of the parent for a reason but I forgot the reason

#

I'll check it out

midnight frigate
#

thanks you

broken dragon
#

I'm planning to fix this today

midnight frigate
broken dragon
#

Alright so I made a new branch

#

I'm not sure if it works or not so I'd appreciate it if you could test

#

pip install -U git+https://github.com/Dorukyum/pycord-multicog@keep-cog

midnight frigate
midnight frigate
broken dragon
#

Great

#

I'll give it a few days

#

Just to make sure

#

Then I'll release it

midnight frigate
#

dont worry i understand

midnight frigate
#

@broken dragon have you plan to add it to the main ? idk why but the

pip install -U git+https://github.com/Dorukyum/pycord-multicog@keep-cog

doesnt work anymore

#

apprently its merge but strange because i have the error of the wrong self

broken dragon
#

I've had my last batch of exams for this year recently, promise I'll publish it in 24h

midnight frigate
broken dragon
midnight frigate
#

Thanks you man ;​​​ )​

broken dragon
#

No problem