Closed vliberio closed 3 years ago
Thank you for your contribution! I'm not sure how this happened, I'm guessing I never noticed the problem because of the driver I'm using 🤔 Maybe Red should have the same behavior on all drivers, but oh well 🤷
Hey, someone reported that this change causes an error for people with existing configs:
Exception during loading of package
Traceback (most recent call last):
File "/home/creepr/oee_lol/lib/python3.8/site-packages/redbot/core/core_commands.py", line 175, in _load
await bot.load_extension(spec)
File "/home/creepr/oee_lol/lib/python3.8/site-packages/redbot/core/bot.py", line 1609, in load_extension
lib.setup(self)
File "/home/creepr/main/DamkMemez/cogs/CogManager/cogs/react_roles/__init__.py", line 6, in setup
bot.add_cog(ReactRoles(bot))
File "/home/creepr/main/DamkMemez/cogs/CogManager/cogs/react_roles/react_roles.py", line 97, in __init__
self.config.init_custom(self.MESSAGE_GROUP, 2)
File "/home/creepr/oee_lol/lib/python3.8/site-packages/redbot/core/config.py", line 995, in init_custom
raise ValueError(
ValueError: Cannot change identifier count of already registered group: MESSAGE
Could you look into a way to make the transition smoother? Otherwise I'll have to revert this change
Oh, loading the updated cog without a full restart of the bot causes the error since init_custom has already been called with number of identifiers of 1. I didn't notice since I had to switch my instance to dev mode and load it. There doesn't seem to be a clean way to change it number of parameters once it's been called according the API reference.
As for other options, changing the MESSAGE_GROUP constant would clearly be out of the question without migrating the data in the existing config custom group and that sounds rather messy, difficult, and over my head. I think I'm gonna see if the Red Discord Bot team can provide any guidance especially in terms of whether bypassing that check in the init_custom method would cause any issues considering the number of identifiers don't appear to matter for anything besides the PostgreSQL backend.
Description The init_custom call in the react_roles init specified 1 identifier instead of 2 (channel and message). This was causing an issue with the PostgreSQL backend (at least from what I can tell) when attempting to use the 'reactroles add' command. I attached below the error it was throwing. Changing the identifier_count from 1 to 2 fixed this.
Previous Error react_roles error.txt
Notes I spent a bit too long looking into Red's code thinking this was some weird behavior/issue with its PostgreSQL driver. It turned out to be a lot simpler than I was expecting.