Search docs
Search guides, modules and symbols
Modules

Docs / API / Modules / bans

Bans

Admin & chat

@s2script/sdk/bans

Host-global SteamID64 ban cache. Bans.add updates the cache then attempts persistence (void; no rollback). Bans.remove returns whether a cache key existed, not disk ACK.

Import

import { BanInfo } from "@s2script/sdk/bans";

Author-time types ship in the npm package; the engine injects the runtime at plugin load. Add @s2script/sdk to your plugin's dependencies.

API reference

Generated from the shipped type definitions.

interface
BanInfo

A ban entry's value: expiry + reason. until === 0 = permanent, else unix-second expiry.

until: number
— Unix-second expiry, or 0 for a permanent ban.
reason: string
— The ban reason (may be empty).
interface
BanEntry

A ban entry as listed by Bans.list(): the SteamID64 plus its value.

steamid: string
— The banned SteamID64 (decimal string).
until: number
— Unix-second expiry, or 0 for a permanent ban.
reason: string
— The ban reason (may be empty).
const
Bans

The ban API: add/remove bans, look up by SteamID64, list, and reload from bans.json.

import { Bans } from "@s2script/sdk/bans";
// Connect-time enforcement inside a Clients.onConnect handler.
const b = Bans.get(c.steamId);
if (b && (b.until === 0 || b.until > Date.now() / 1000)) c.kickWithReason(b.reason);
add(steamId: string, minutes: number, reason?: string): void
— Add/overwrite the host cache, then attempt to rewrite bans.json. Returns void; persistence failure is not acknowledged and does not roll back the cache. An immediate get() confirms cache visibility only, not a fresh or durable write. minutes <= 0 = permanent.
remove(steamId: string): boolean
— Remove from cache and attempt persistence. Returns whether a cache key existed, not disk acknowledgement.
get(steamId: string): BanInfo | null
— Get a ban by SteamID64, or null if not banned.
list(): BanEntry[]
— List every ban currently in the cache.
reload(): void
— Re-read bans.json into the cache (clears the old cache first).
Back to modules All packages