MrHemlock / auto_guild

Creates a Discord server based on a template you layout, making it an easy and quick way to flesh out a server to fit your needs.
MIT License
13 stars 0 forks source link

Arbitrary Constructors and Variables #7

Open HassanAbouelela opened 2 years ago

HassanAbouelela commented 2 years ago

The YAML library allows you to add arbitrary constructors, and use variables which are parsed at runtime in your config. Here are a few examples:

https://github.com/python-discord/bot/blob/b91820a30af9dcae0c1952432639661889c74970/config-default.yml#L360-L362

https://github.com/python-discord/bot/blob/b91820a30af9dcae0c1952432639661889c74970/config-default.yml#L369-L372

These are currently unsupported by the tool, as it'll error on the unknown constructors, and won't carry variables across. This is problematic as it means end users will have to modify their configs by hand at the end to add the variables back, and config makers can't use any constructors.

I see a few possible options here:

  1. Allow users to define arbitrary constructors/loaders and pass them to the package. There is more information about this in the documentation under Constructors, representers, resolvers.
  2. Ignore unrecognized constructors and just spit them back out at the end. I'm not sure how the implementation for this will work, but it should still allow users to use constructors as they like.
MrHemlock commented 2 years ago

This is way beyond the scope of what this script is for. It's meant to be run using the specific layouts I specified. If anything, this would generate the config.yaml and you just add on the relevant extra stuff you need. This wouldn't require you to add anything back. The config-default.yaml stuff would still apply. You only would need to add what you're modifying. So there shouldn't be any additional moving by hand stuff.

Unless I'm misunderstanding.

HassanAbouelela commented 2 years ago

We do use variables for roles and channels at the very least, so it would mean you'd need to modify the output of the script by hand to include those variables.

You'd also need to copy across other stuff that needs to be modified and modify it (such as the variables for the site API I linked in the original message). This would also mean having to maintain a fourth unrelated list of variables that aren't in the auto-guild config, but you need to add by hand.