<commit_before>const SettingResolver = require('../parsers/SettingResolver');
const CacheManager = require('./CacheManager');
const SchemaManager = require('./SchemaManager');
const SQL = require('./SQL');

/**
 * The gateway to all settings
 * @extends {CacheManager}
 */
class SettingGateway extends CacheManager {

	/**
	 * @param {KlasaClient} client The Klasa Client
	 */
	constructor(client) {
		super(client);

		/** @type {Client} */
		this.client = client;

		/** @type {string} */
		this.engine = client.config.provider.engine || 'json';

		this.resolver = new SettingResolver(client);
		this.schemaManager = new SchemaManager(this.client);
	}

	/**
	 * Initialize the configuration for all Guilds.
	 * @returns {void}
	 */
	async init() {
		this.provider = this.client.providers.get(this.engine);
		if (!this.provider) throw `This provider (${this.engine}) does not exist in your system.`;
		await this.schemaManager.init();
		this.sql = this.provider.sql ? new SQL(this.client, this.provider) : false;
		if (!await this.provider.hasTable('guilds')) {
			const SQLCreate = this.sql ? this.sql.buildSQLSchema(this.schema) : undefined;
			await this.provider.createTable('guilds', SQLCreate);
		}
		const data = await this.provider.getAll('guilds');
		if (this.sql) {
			this.sql.initDeserialize();
			for (let i = 0; i < data.length; i++) this.sql.deserializer(data[i]);
		}
		if (data[0]) for (const key of data) super.set(key.id, key);
	}

	/**
	 * Get the current DataSchema.
	 * @readonly
	 * @returns {Object}
	 */
	get schema() {
		return this.schemaManager.schema;
	}

	/**
	 * Get the default values from the current DataSchema.
	 * @readonly
	 * @returns {Object}
	 */
	get defaults() {
		return this.schemaManager.defaults;
	}

	/**
	 * Create a new Guild entry for the configuration.
	 * @param {Guild|Snowflake} guild The Guild object or snowflake.
	 * @returns {void}
	 */
	async create(guild) {
		const target = await this.validateGuild(guild);<commit_msg>settingGateway provider getter, so reloading works<commit_after>const SettingResolver = require('../parsers/SettingResolver');
const CacheManager = require('./CacheManager');
const SchemaManager = require('./SchemaManager');
const SQL = require('./SQL');

/**
 * The gateway to all settings
 * @extends {CacheManager}
 */
class SettingGateway extends CacheManager {

	/**
	 * @param {KlasaClient} client The Klasa Client
	 */
	constructor(client) {
		super(client);

		/** @type {Client} */
		this.client = client;

		/** @type {string} */
		this.engine = client.config.provider.engine || 'json';

		this.resolver = new SettingResolver(client);
		this.schemaManager = new SchemaManager(this.client);
	}

	/**
	 * Initialize the configuration for all Guilds.
	 * @returns {void}
	 */
	async init() {
		if (!this.provider) throw `This provider (${this.engine}) does not exist in your system.`;
		await this.schemaManager.init();
		this.sql = this.provider.sql ? new SQL(this.client, this.provider) : false;
		if (!await this.provider.hasTable('guilds')) {
			const SQLCreate = this.sql ? this.sql.buildSQLSchema(this.schema) : undefined;
			await this.provider.createTable('guilds', SQLCreate);
		}
		const data = await this.provider.getAll('guilds');
		if (this.sql) {
			this.sql.initDeserialize();
			for (let i = 0; i < data.length; i++) this.sql.deserializer(data[i]);
		}
		if (data[0]) for (const key of data) super.set(key.id, key);
	}

	/**
	 * Get the current provider.
	 * @readonly
	 * @returns {Provider}
	 */
	get provider() {
		return this.client.providers.get(this.engine);
	}

	/**
	 * Get the current DataSchema.
	 * @readonly
	 * @returns {Object}
	 */
	get schema() {
		return this.schemaManager.schema;
	}

	/**
	 * Get the default values from the current DataSchema.
	 * @readonly
	 * @returns {Object}
	 */
	get defaults() {
		return this.schemaManager.defaults;
	}

	/**
	 * Create a new Guild entry for the configuration.
	 * @param {Guild|Snowflake} guild The Guild object or snowflake.
	 * @returns {void}
	 */
	async create(guild) {
		const target = await this.validateGuild(guild);
{'fraction_non_alphanumeric': 0.15019569471624267, 'fraction_numerical': 0.0009784735812133072, 'mean_word_length': 3.7271676300578034, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5506549', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1271, 'n_words': 339}