<commit_before><?php
/**
 * @param string $url New Discord bot URL
 * @param string $id New Discord Guild/server ID
 *
 * @return string JSON Array
 */
class UpdateDiscordBotSettingsEndpoint extends EndpointBase {

	public function __construct() {
		$this->_route = 'updateDiscordBotSettings';
		$this->_module = 'Core';
		$this->_description = 'Updates the Discord Bot URL and/or Guild ID setting';
	}

	public function execute(Nameless2API $api) {
		if ($api->isValidated()) {
			
			if (!isset($_POST['url']) && !isset($_POST['guild_id'])) {
				$api->throwError(31, $api->getLanguage()->get('api', 'provide_one_discord_settings'));
			}

			if (isset($_POST['url'])) {
				try {
					$api->getDb()->createQuery('UPDATE nl2_settings SET `value` = ? WHERE `name` = ?', array($_POST['url'], 'discord_bot_url'));
				} catch (Exception $e) {
					$api->throwError(30, $api->getLanguage()->get('api', 'unable_to_set_discord_bot_url'));
				}
			}

			if (isset($_POST['guild_id'])) {
				try {
					$api->getDb()->createQuery('UPDATE nl2_settings SET `value` = ? WHERE `name` = ?', array($_POST['guild_id'], 'discord'));
				} catch (Exception $e) {
					$api->throwError(30, $api->getLanguage()->get('api', 'unable_to_set_discord_id'));
				}
			}

			$api->returnArray(array('message' => $api->getLanguage()->get('api', 'discord_bot_url_updated')));
		}
	}
}<commit_msg>fix endpoint url json array<commit_after><?php
/**
 * @param string $url New Discord bot URL
 * @param string $id New Discord Guild/server ID
 *
 * @return string JSON Array
 */
class UpdateDiscordBotSettingsEndpoint extends EndpointBase {

	public function __construct() {
		$this->_route = 'updateDiscordBotSettings';
		$this->_module = 'Core';
		$this->_description = 'Updates the Discord Bot URL and/or Guild ID setting';
	}

	public function execute(Nameless2API $api) {
		if ($api->isValidated()) {
			
			if (!isset($_POST['url']) && !isset($_POST['guild_id'])) {
				$api->throwError(31, $api->getLanguage()->get('api', 'provide_one_discord_settings'));
			}

			if (isset($_POST['url'])) {
				$url = json_decode($_POST['url'], true)['url'];
				try {
					$api->getDb()->createQuery('UPDATE nl2_settings SET `value` = ? WHERE `name` = ?', array($url, 'discord_bot_url'));
				} catch (Exception $e) {
					$api->throwError(30, $api->getLanguage()->get('api', 'unable_to_set_discord_bot_url'));
				}
			}

			if (isset($_POST['guild_id'])) {
				try {
					$api->getDb()->createQuery('UPDATE nl2_settings SET `value` = ? WHERE `name` = ?', array($_POST['guild_id'], 'discord'));
				} catch (Exception $e) {
					$api->throwError(30, $api->getLanguage()->get('api', 'unable_to_set_discord_id'));
				}
			}

			$api->returnArray(array('message' => $api->getLanguage()->get('api', 'discord_bot_url_updated')));
		}
	}
}
{'fraction_non_alphanumeric': 0.19757056091461236, 'fraction_numerical': 0.006430868167202572, 'mean_word_length': 4.458089668615984, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '4556050', 'n_tokens_mistral': 1082, 'n_tokens_neox': 945, 'n_words': 185}