There is an extra module organize_group which seems to be a good start, since this would mess up the text commands. However there are still dozens of calls of the helper functions which require a lot of context.
Maybe its worth to use a Group or GroupManager class, that can be initialized from the guild + group name, reads all data from the yaml file and everything can be accessed from there.. Just a very rough Idea in pseudo code:
# in organize_groups
class Group():
def init():
self.guild = guild
self.name = name
def load():
self.loaded = true
data = read_yaml()[self.guild][self.name]
self.owner_id = data['owner']
...
@property
def owner():
if not self.loaded: self.load() # only read yaml if data is accessed
return discord.get_user(self.owner_id)
# in commands or wherever in the bot
group = Group(ctx.guild, group_name)
group.name
group.owner
group.add_member(ctx.author)
group.save()
maybe its a even a case for a context manager. I need to read about it first.. (dont really know how to use them properly).
If we think about switching to a database or something like sqlite at some point I'd move all this logic to the ORM layer, than we don't need to worry about it at all.
There is an extra module
organize_group
which seems to be a good start, since this would mess up the text commands. However there are still dozens of calls of the helper functions which require a lot of context.Maybe its worth to use a Group or GroupManager class, that can be initialized from the guild + group name, reads all data from the yaml file and everything can be accessed from there.. Just a very rough Idea in pseudo code:
maybe its a even a case for a context manager. I need to read about it first.. (dont really know how to use them properly). If we think about switching to a database or something like sqlite at some point I'd move all this logic to the ORM layer, than we don't need to worry about it at all.