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
#Really strange
1 messages · Page 1 of 1 (latest)
It told me about another class that i dont even have in the file and that i dont even have imported
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
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
thanks you
I'm planning to fix this today
thanks you for this man
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
I will try to test that today
i tried your fix and it seems to work perfectly. Everything is working if im facing anything i will tell you
dont worry i understand
@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
I've had my last batch of exams for this year recently, promise I'll publish it in 24h
dont worry exam is more important, focus on it before
I got you, it's published now
Thanks you man ; )
No problem