Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions app/[lang]/(site)/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { pageSeo } from '@/lib/pageSeo'
import { publicPath } from '@/lib/routes'
import { alternatesFor, openGraphFor } from '@/lib/seo'
import { getRequestLang } from '@/lib/serverLang'
import { loadShopStats } from '@/lib/shopStats'
import { loadDiscordMemberCount } from '@/lib/discordMembers'

/**
* `/en/about` and `/de/ueber-msk`: the person behind MSK Scripts (plan 5.2,
Expand Down Expand Up @@ -43,18 +43,17 @@ export async function generateMetadata(): Promise<Metadata> {
}

export default async function AboutPage() {
const [{ lang }, stats, headline, docPages] = await Promise.all([
const [{ lang }, discordMembers, headline, docPages] = await Promise.all([
getRequestLang(),
// Fail-soft: a source that fails drops its figure, nothing is estimated.
loadShopStats().catch(() => null),
loadDiscordMemberCount().catch(() => null),
loadHeadlineStat().catch(() => null),
loadDocPageCount().catch(() => null),
])
const t = aboutPageTranslations[lang]
const home = homeTranslations[lang]
const nav = layoutTranslations[lang]
const locale = lang === 'de' ? 'de-DE' : 'en-GB'
const measured = aboutFigures(lang, stats, headline?.serverCount ?? null, docPages)
const measured = aboutFigures(lang, discordMembers, headline?.serverCount ?? null, docPages)

const facts: Array<[string, React.ReactNode]> = [
[t.fact_brand, 'MSK Scripts'],
Expand Down Expand Up @@ -154,11 +153,6 @@ export default async function AboutPage() {
</div>
))}
</dl>
{stats && (
<p className="text-small text-[var(--color-muted-foreground)]">
{t.n_asof.replace('{date}', stats.updatedAt.toLocaleDateString(locale, { day: 'numeric', month: 'long', year: 'numeric' }))}
</p>
)}
</div>
</Section>
)}
Expand Down
10 changes: 5 additions & 5 deletions app/[lang]/(site)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { JsonLd } from '@/components/JsonLd'
import { webSiteJsonLd } from '@/lib/jsonLd'
import { loadHeadlineStat } from '@/lib/fivestats'
import { loadDocPageCount } from '@/lib/docsPages'
import { loadShopStats } from '@/lib/shopStats'
import { loadDiscordMemberCount } from '@/lib/discordMembers'
import { cheapestPaidTier, formatTierPrice } from '@/lib/tiers'

// The home page collects impressions on generic queries for
Expand Down Expand Up @@ -50,16 +50,16 @@ export async function generateMetadata(): Promise<Metadata> {
* cards and the second closing section (exclusion list, plan 4.2).
*/
export default async function HomePage() {
const [{ lang }, headline, stats, docPages] = await Promise.all([
const [{ lang }, headline, discordMembers, docPages] = await Promise.all([
getRequestLang(),
// Fail-soft: none of these sources may take down the home page. If one
// fails, the corresponding figure disappears; nothing is estimated.
loadHeadlineStat().catch(err => {
console.warn('[home] fivestats headline stat unavailable:', err)
return null
}),
loadShopStats().catch(err => {
console.warn('[home] shop stats unavailable:', err)
loadDiscordMemberCount().catch(err => {
console.warn('[home] discord member count unavailable:', err)
return null
}),
loadDocPageCount().catch(err => {
Expand All @@ -76,7 +76,7 @@ export default async function HomePage() {
Only here: the home page is the one address that stands for the site. */}
<JsonLd data={webSiteJsonLd()} />
<Hero lang={lang} botFrom={ticketFrom} />
<ProofLine lang={lang} stats={stats} servers={headline} docPages={docPages} />
<ProofLine lang={lang} discordMembers={discordMembers} servers={headline} docPages={docPages} />
<Bots lang={lang} ticketFrom={ticketFrom} />
<WebTools lang={lang} />
<FreeScripts lang={lang} />
Expand Down
19 changes: 11 additions & 8 deletions components/home/ProofLine.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LocaleLink as Link } from '@/components/i18n/LocaleLink'
import { homeTranslations, type Lang } from '@/lib/i18n'
import type { ShopStats } from '@/lib/shopStats'
import type { HeadlineStat } from '@/lib/fivestats'
import { SITE_CONFIG } from '@/lib/config'

Expand All @@ -15,8 +14,7 @@ import { SITE_CONFIG } from '@/lib/config'
*
* An entry whose source is unavailable is dropped rather than replaced with an
* estimate: a line of three numbers of which one is invented teaches the
* reader to discount the other two. The refund rate is not here; it belongs
* on the about page (E6).
* reader to discount the other two.
*/

interface Entry {
Expand All @@ -27,10 +25,11 @@ interface Entry {
}

export function ProofLine({
lang, stats, servers, docPages,
lang, discordMembers, servers, docPages,
}: {
lang: Lang
stats: ShopStats | null
/** Members of the MSK Discord, from its invite. `null` when unreachable. */
discordMembers: number | null
servers: HeadlineStat | null
/** Documentation pages, counted from its sitemap. `null` when unreachable. */
docPages: number | null
Expand All @@ -39,7 +38,11 @@ export function ProofLine({
const num = (n: number) => n.toLocaleString(lang === 'de' ? 'de-DE' : 'en-GB')

const entries: Entry[] = []
if (stats) entries.push({ value: num(stats.uniqueBuyers), label: t.proof_buyers })
// Until 05.11.2026 this was "unique buyers" from the Tebex shop, which no
// longer sells anything. Support runs through the Discord now.
if (discordMembers !== null) {
entries.push({ value: num(discordMembers), label: t.proof_discord, href: SITE_CONFIG.discord, external: true })
}
if (servers) entries.push({ value: num(servers.serverCount), label: t.proof_servers, href: '/stats' })
// Until 05.09.2026 this was a constant `206`; the real figure was 208. If
// the source fails, the entry drops out, same as the other two.
Expand All @@ -55,9 +58,9 @@ export function ProofLine({

return (
<section aria-label={t.proof_label} className="border-b border-[var(--color-border)]">
<dl className="container-page flex flex-wrap gap-x-[clamp(2rem,4vw,6rem)] gap-y-4 py-[clamp(1.25rem,1rem+1vw,2.25rem)]">
<dl className="container-page flex flex-wrap justify-center gap-x-[clamp(2rem,4vw,6rem)] gap-y-4 py-[clamp(1.25rem,1rem+1vw,2.25rem)]">
{entries.map(e => (
<div key={e.label} className="flex flex-col-reverse">
<div key={e.label} className="flex flex-col-reverse items-center text-center">
<dt>
{e.href && e.external ? (
<a href={e.href} target="_blank" rel="noopener noreferrer" className={linkClass}>{e.label}</a>
Expand Down
44 changes: 10 additions & 34 deletions lib/aboutFigures.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { SITE_CONFIG } from '@/lib/config'
import { aboutPageTranslations, type Lang } from '@/lib/i18n'
import { formatReversalRate, type ShopStats } from '@/lib/shopStats'

/**
* The measured figures of the about page, each with the source a reader can
* check it against. A figure whose source failed is left out, never
* estimated: a list of five numbers of which one is invented teaches the
* reader to discount the other four.
* estimated: a list of numbers of which one is invented teaches the reader
* to discount the others.
*
* The share of refunded or charged-back payments is here and not on the home
* page (decision E6 of the redesign plan). It is the `reversal_rate` that
* scripts/tebex-stats.js writes nightly: refunds plus chargebacks over all
* settled payments. The counts beside it come from the same row, so rate and
* counts cannot describe two different nights.
* Until 05.11.2026 the list also held the shop figures from the nightly Tebex
* snapshot (unique buyers, refund rate, first sale). The shop stopped selling
* FiveM scripts that day, so those figures would only describe the past.
*/

export interface AboutFigure {
Expand All @@ -25,43 +22,22 @@ export interface AboutFigure {

export function aboutFigures(
lang: Lang,
stats: ShopStats | null,
discordMembers: number | null,
servers: number | null,
docPages: number | null,
): AboutFigure[] {
const t = aboutPageTranslations[lang]
const locale = lang === 'de' ? 'de-DE' : 'en-GB'
const num = (n: number) => n.toLocaleString(locale)
const num = (n: number) => n.toLocaleString(lang === 'de' ? 'de-DE' : 'en-GB')
const out: AboutFigure[] = []

if (stats) out.push({ value: num(stats.uniqueBuyers), label: t.n_buyers, source: t.n_buyers_source })
if (discordMembers !== null && discordMembers > 0) {
out.push({ value: num(discordMembers), label: t.n_discord, source: t.n_discord_source, href: SITE_CONFIG.discord, external: true })
}
if (servers !== null && servers > 0) {
out.push({ value: num(servers), label: t.n_servers, source: t.n_servers_source, href: '/stats' })
}
if (docPages !== null && docPages > 0) {
out.push({ value: num(docPages), label: t.n_docs, source: t.n_docs_source, href: SITE_CONFIG.docs, external: true })
}
if (stats) {
const settled = stats.completedPayments + stats.refunds + stats.chargebacks
// Without a settled payment the rate is 0 by default, not by measurement.
if (settled > 0) {
const rate = formatReversalRate(stats.reversalRate, lang)
out.push({
value: lang === 'de' ? `${rate} %` : `${rate}%`,
label: t.n_reversal,
source: t.n_reversal_source
.replace('{refunds}', num(stats.refunds))
.replace('{chargebacks}', num(stats.chargebacks))
.replace('{settled}', num(settled)),
})
}
if (stats.firstPaymentAt && !Number.isNaN(stats.firstPaymentAt.getTime())) {
out.push({
value: stats.firstPaymentAt.toLocaleDateString(locale, { month: 'long', year: 'numeric' }),
label: t.n_first,
source: t.n_buyers_source,
})
}
}
return out
}
67 changes: 67 additions & 0 deletions lib/discordMembers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// NOTE: server module. No secret behind it: Discord answers an invite lookup
// without a token. Fetching it server-side happens once per hour instead of
// once per page view, and the figure is already in the delivered markup.

import { SITE_CONFIG } from '@/lib/config'

/**
* How many members the MSK Scripts Discord has.
*
* Replaces "unique buyers" under the hero and on the about page since
* 05.11.2026, when the paid FiveM scripts went free and the shop stopped
* selling them. Support now runs through that Discord (public channel, tickets
* for GitHub sponsors), so its size is the figure that fits.
*
* The source is Discord's public invite endpoint with `with_counts=true`. Its
* `approximate_member_count` is what Discord itself shows on the invite card,
* so a reader can check it by opening the invite.
*/

const INVITE_API = 'https://discord.com/api/v10/invites/{code}?with_counts=true'

/** One hour. The count moves slowly and Discord rate-limits this endpoint. */
const REVALIDATE_SECONDS = 3600

/** `https://discord.gg/abc123` -> `abc123`. `null` for anything else. */
export function inviteCode(url: string): string | null {
const match = /^https:\/\/(?:www\.)?discord(?:\.gg|(?:app)?\.com\/invite)\/([A-Za-z0-9-]+)\/?$/.exec(url)
return match ? match[1] : null
}

/**
* The member count from an invite response, or `null` when it is missing or
* not a positive whole number. A zero would be a broken answer, not an empty
* server: the invite belongs to a server with members.
*/
export function memberCountFrom(body: unknown): number | null {
if (typeof body !== 'object' || body === null) return null
const count = (body as { approximate_member_count?: unknown }).approximate_member_count
return typeof count === 'number' && Number.isInteger(count) && count > 0 ? count : null
}

/**
* Returns the count, or `null` when it cannot be determined. Same rule as the
* other measured figures: a source that fails drops its entry, nothing is
* estimated or frozen.
*/
export async function loadDiscordMemberCount(): Promise<number | null> {
const code = inviteCode(SITE_CONFIG.discord)
if (!code) {
console.error('[discordMembers] SITE_CONFIG.discord is not an invite link')
return null
}
try {
const res = await fetch(INVITE_API.replace('{code}', code), {
headers: { accept: 'application/json' },
next: { revalidate: REVALIDATE_SECONDS },
})
if (!res.ok) {
console.error(`[discordMembers] invite lookup responded ${res.status}`)
return null
}
return memberCountFrom(await res.json())
} catch (e) {
console.error('[discordMembers] could not read the invite:', e)
return null
}
}
23 changes: 7 additions & 16 deletions lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1970,9 +1970,9 @@ export const homeTranslations = {
entry_tools_price: "Free",

// Measured figures under the hero. Every number is measured, see
// PRODUCT.md -> Evidence on Hand. The refund rate is not here (E6).
// PRODUCT.md -> Evidence on Hand.
proof_label: "MSK Scripts in numbers",
proof_buyers: "unique buyers",
proof_discord: "members on Discord",
proof_servers: "servers running msk_core",
proof_docs: "documentation pages",

Expand Down Expand Up @@ -2034,7 +2034,7 @@ export const homeTranslations = {
entry_tools_price: "Kostenlos",

proof_label: "MSK Scripts in Zahlen",
proof_buyers: "einzigartige Käufer",
proof_discord: "Mitglieder im Discord",
proof_servers: "Server auf msk_core",
proof_docs: "Doku-Seiten",

Expand Down Expand Up @@ -2170,17 +2170,12 @@ export const aboutPageTranslations = {
numbers_title: "Measured, not estimated",
numbers_intro:
"Each figure comes from a source that can be checked. If a source cannot be reached, its figure is left out rather than estimated.",
n_buyers: "unique buyers",
n_buyers_source: "Accounts with at least one completed payment in the shop",
n_discord: "members on Discord",
n_discord_source: "Live count from the invite of the MSK Scripts Discord",
n_servers: "servers running msk_core",
n_servers_source: "Live count from fivestats.io",
n_docs: "documentation pages",
n_docs_source: "Counted from the sitemap of the documentation",
n_reversal: "of settled payments refunded or charged back",
// {refunds}, {chargebacks} and {settled} are counts from the same snapshot.
n_reversal_source: "{refunds} refunds and {chargebacks} chargebacks out of {settled} settled payments",
n_first: "first sale on record",
n_asof: "Shop figures as of {date}, updated nightly.",
links_kicker: "Where to find him",
links_title: "Discord, GitHub and the rest",
link_discord: "Support and questions, answered by the developer",
Expand Down Expand Up @@ -2217,16 +2212,12 @@ export const aboutPageTranslations = {
numbers_title: "Gemessen, nicht geschätzt",
numbers_intro:
"Jede Zahl stammt aus einer Quelle, die sich prüfen lässt. Ist eine Quelle nicht erreichbar, fehlt ihre Zahl, statt geschätzt zu werden.",
n_buyers: "einzigartige Käufer",
n_buyers_source: "Konten mit mindestens einer abgeschlossenen Zahlung im Shop",
n_discord: "Mitglieder im Discord",
n_discord_source: "Live-Zahl aus der Einladung des MSK-Scripts-Discords",
n_servers: "Server auf msk_core",
n_servers_source: "Live-Zahl von fivestats.io",
n_docs: "Doku-Seiten",
n_docs_source: "Gezählt aus der Sitemap der Dokumentation",
n_reversal: "der abgerechneten Zahlungen erstattet oder zurückgebucht",
n_reversal_source: "{refunds} Erstattungen und {chargebacks} Rückbuchungen bei {settled} abgerechneten Zahlungen",
n_first: "erster Verkauf",
n_asof: "Shop-Zahlen vom {date}, nachts aktualisiert.",
links_kicker: "Wo du ihn findest",
links_title: "Discord, GitHub und der Rest",
link_discord: "Support und Fragen, beantwortet vom Entwickler",
Expand Down
Loading
Loading