Closed manulaiko closed 6 years ago
The issue is that implementation varies drastically by how your bot stores information. A default or example implementation would be possible but also useless for all or almost all bots. Is there something in specific that you think needs more clarification in the docs?
If I've understood correctly from the code, an instance of GuildSettingsManager
is provided to the builder.
From CommandClientImpl
you can retrieve it and get specific settings from a guild.
However, what a setting is or what a GuildSettingsManager is, isn't specified.
Does GuildSettingsManager
represent a specific setting (e.g.: EnableCommands
) or it represents a manager of all settings?
I really can't find a way to use the interfaces. It would be more easier if you GuildSettingsManager
had a method findSettingsFor(Class<? extend Setting> type, Guild guild)
which you would implement to return a Setting
instance with the value of the setting for guild
:
public class SettingsManager implements GuildSettingsManager {
public <T extends Setting> T findSettingsFor(Class<T> type, Guild guild) {
String setting = Database.select("value")
.from("guild_settings")
.where("name", type.getSimpleName())
.and("guild_id", guild.getID());
if (setting != null) {
return new T(setting);
}
return null;
}
}
And that would provide a way for CommandClientImpl
to do the same that what apparently does right now:
builder.setGuildSettingsManager(new SettingsManager());
// ...
EnableCommand ec = event.getClient().getSettingFor(EnableCommand.class, event.getGuild);
The issue tracker is for bug reports and feature suggestions. If you have any questions feel free to ask them in the #jda-utilities channel on the official JDA guild.
The JavaDoc for
GuildSettingsManager
andGuildSettingsProvider
tells what they do but not how they should be implemented.It would be nice to have a simple implementation code in the class-level JavaDoc so we can have a guideline on how to use it.