feat(rust): slash commands and the next wipe, server half (phase 16)
Five read-only commands registered with api.registerSlashCommands: /status, /wipe, /top, /online and /clan (D126). Every refusal is private, and any answer narrower than public (online names, a clan roster) goes to the caller alone (D127). No command asks a sidecar. The next wipe (D128, D130): six nullable columns on rust_servers, a pure nextWipe(row, now) with the zone arithmetic through Intl, computed on every read. The public server shape gains nextWipe; the admin shape gains the stored schedule; PUT /admin/rust/servers/:id takes the six fields and writes them only when wipeRule is present. server/commands joins ci/bundle.json, which checkBundle caught. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
38
server/commands/wipe.command.js
Normal file
38
server/commands/wipe.command.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// ── `/wipe [server]` — when it wipes next, and when it last did (D128) ──────
|
||||
//
|
||||
// Public: a wipe date is announced to bring players back. The next wipe is the
|
||||
// operator's schedule, computed on this read (`model/servers/nextWipe.js`); a
|
||||
// server with no schedule says so and shows only the last wipe it reported.
|
||||
|
||||
const c = require('./common')
|
||||
|
||||
function lines(server, now) {
|
||||
return [
|
||||
`Next: ${c.nextWipeText(server, now) || 'no schedule set'}`,
|
||||
`Last: ${server.wipedAt ? c.when(server.wipedAt, now) : 'not reported yet'}`,
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
async function handler({ options }) {
|
||||
const now = Date.now()
|
||||
const picked = c.pickServer(await c.listServers(now), options && options.server)
|
||||
const refusal = c.pickRefusal(picked)
|
||||
if (refusal) return refusal
|
||||
|
||||
if (picked.server) {
|
||||
return { title: `${picked.server.name} — wipes`, url: c.serverUrl(picked.server), text: lines(picked.server, now) }
|
||||
}
|
||||
return {
|
||||
title: 'Wipes',
|
||||
url: c.pageUrl('/rust'),
|
||||
fields: picked.all.slice(0, 25).map((s) => ({ name: s.name, value: lines(s, now), inline: false })),
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'wipe',
|
||||
description: 'When a Rust server wipes next, and when it last wiped',
|
||||
options: [{ name: 'server', type: 'string', description: 'Server name or id (all servers when left out)', required: false }],
|
||||
access: 'everyone',
|
||||
handler,
|
||||
}
|
||||
Reference in New Issue
Block a user