config
API Reference from the config related classes in the API
The config related classes allow you to read the open ticket configs in a controlled way. You are also able to register your own config(s) for your plugin. This way people can configure your config while it still looks a little bit like open ticket itself.
Table of contents
This class represents a config JSON file. You can create your own config or use the default open ticket configs.
This Class is a collection of all available config files registered by open ticket & plugins. It is shared with all plugins, this way they can also read the config files from other plugins.
class OTConfig:
constructor(id: String|OTId, file:String, customPath?: String) => OTConfig
This method creates the OTConfig class. It tries to read the config JSON file and stores it in the data variable. It needs to be registered in an OTConfigManager class. The class normally reads the JSON files from the default ./config/ directory. When customPath is specified, it will read from the specified location
//load the /config/test.json config file and register it to the manager
openticket.config.addConfig(new api.OTConfig("testconfig_id","test.json"))
//load the /random/idk.json config file and register it to the manager
openticket.config.addConfig(new api.OTConfig("idk_id","idk.json","random/"))class variables:
data
Object
The contents of the JSON config file.
file
String
The filename of the config. For example general.json
class OTConfigManager:
Warning! This class should only be created & registered by Open Ticket itself. Plugins need this class to function properly. Replacing/extending this class could resolve in issues with other plugins
constructor() => OTConfigManager The constructor of this class has no inputs and just loads the manager. It has no other special use.
addConfig(object: OTConfig) => undefined Add an OTConfig object to the collection and make it that other plugins are able to access the config file.
findConfig(id: String|OTId) => OTConfig Find an OTConfig by id. The id is specified when constructing the OTConfig object.
removeConfig(id: String|OTId) => OTConfig|false Remove a config from the collection, now it isn't accessible anymore to other plugins! If possible, the function returns the OTConfig object that got removed.
class variables:
Last updated
Was this helpful?