Skip to content
This repository has been archived by the owner on Feb 22, 2021. It is now read-only.

Using the Server based preference System

Tobias Burdow [Kaleidox] edited this page May 24, 2019 · 1 revision

The artifact comes with a preference system that can be used to store properties per server; effectively enabling for simple per-server bot configuration. The following is an example on how to use the preference system, and how to use the built-in per-server command prefix:

// Create an instance of the system using a file object where the preferences should be stored
ServerPropertiesManager properties = new ServerPropertiesManager(new File("data/properties.json"));

// Register your properties
// In this example, we register a custom prefix property and tell the command framework to use this prefix
PropertyGroup customPrefixProperty = properties.register("bot.prefix", "dango!");

// Tell the command framework to use the registered property for prefixes as well
// The second argument will tell the command framework whether this custom prefix should be used exclusively. 
// If set to FALSE, the bot will also respond to the default command prefixes.
framework.useCustomPrefix(customPrefixProperty, false);

// Registering the property-command to enable the moderators of servers to modify the properties
// This command can be used by anyone in a server who effectively has the MANAGE_SERVER permission.
properties.usePropertyCommand(DefaultEmbedFactory.INSTANCE, framework);
Clone this wiki locally