*/ function load_messages(string $locale): array { $path = dirname(__DIR__) . '/lang/' . $locale . '.php'; /** @var array $messages */ $messages = require $path; return $messages; } function t(array $messages, string $key, ?string $fallback = null): string { $parts = explode('.', $key); $value = $messages; foreach ($parts as $part) { if (!is_array($value) || !array_key_exists($part, $value)) { return $fallback ?? $key; } $value = $value[$part]; } return is_string($value) ? $value : ($fallback ?? $key); } function bot_invite_url(array $config): string { return 'https://discord.com/api/oauth2/authorize?' . http_build_query([ 'client_id' => (string) $config['bot_client_id'], 'permissions' => '8', 'scope' => 'bot applications.commands', ], '', '&', PHP_QUERY_RFC3986); }