`rolestats` autocomplete results mutate after first use
Fix the bug where rolestats
autocomplete results mutate on first invocation since stats.role_categories
was initialized or updated.
The autocomplete results are accurate for the first use. Once the command is issued, the next viewing of the autocomplete options contain additional values: "title" and "user_label". These are invalid options and are added due to faulty logic. On line 74-77 of cmds/role_stats.py
, those attributes are intended to be added to a category that doesn't have them set. Instead, they're added to the top level of the settings, creating those options.
This was a bit confusing to me, as it appeared that the guild config key's value cached in self._bot.config_data
was being mutated by the aforementioned logic. That appeared true even though the method returning it wasn't a property with a setter. Apparently this is expected behavior...
Assignment statements in Python do not copy objects, they create bindings between a target and an object.
We need to address the logic that populates default values for role categories within the dictionary configuration. We could also return a copy
of the structure rather than a reference, but I think that'd actually degrade performance. As long as the dictionary is being mutated correctly, it won't be an issue to update the cache.