Hans-Vader/squadjs-plugin-creator-skill
creating-squadjs-plugins
VerifiedUse when creating, writing, or scaffolding a new SquadJS plugin, adding a server-side feature to a Squad server via SquadJS, or deciding whether SquadJS can support a desired behaviour ("can SquadJS detect X / do Y on a Squad server?"). Covers the plugin lifecycle, the full event/RCON capability surface, and the hard limits that make some requests impossible.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.6 KB |
| references/api-reference.md | markdown | 16.8 KB |
| references/event-reliability.md | markdown | 7.0 KB |
| references/installation.md | markdown | 3.1 KB |
| templates/database-plugin.js | script | 3.8 KB |
| templates/discord-plugin.js | script | 2.6 KB |
| templates/minimal-plugin.js | script | 2.7 KB |
templates/discord-plugin.js
View on GitHubimport DiscordBasePlugin from './discord-base-plugin.js';
/**
* DISCORD SQUADJS PLUGIN TEMPLATE — extends DiscordBasePlugin.
*
* Use when the plugin posts to a Discord channel. DiscordBasePlugin:
* - adds the required `discordClient` connector option,
* - fetches `this.channel` from `channelID` in its inherited prepareToMount(),
* - provides sendDiscordMessage({ embed: {...} }) (it wraps `embed` into `embeds`
* and accepts a hex-string OR integer `color`).
*
* Place in <squadjs>/squad-server/plugins/. config.json needs a "discord" connector
* (bot token) and this plugin block with "discordClient": "discord" and a "channelID".
*/
export default class MyDiscordPlugin extends DiscordBasePlugin {
static get description() {
return 'Posts a Discord embed to a configured channel when a teamkill occurs.';
}
static get defaultEnabled() {
return false;
}
static get optionsSpecification() {
return {
...DiscordBasePlugin.optionsSpecification, // provides the required `discordClient` connector
channelID: {
required: true,
description: 'The ID of the Discord channel to post to.',
default: '',
example: '667741905228136459'
},
color: {
required: false,
description: 'Embed color (integer, or a hex string like "FF0000").',
default: 16761867
}
};
}
constructor(server, options, connectors) {
super(server, options, connectors);
this.onTeamkill = this.onTeamkill.bind(this);
}
// prepareToMount() is inherited — it sets this.channel from this.options.channelID.
async mount() {
this.server.on('TEAMKILL', this.onTeamkill);
this.verbose(1, 'Mounted.');
}
async unmount() {
// removeListener / off — never removeEventListener (does not exist, throws).
this.server.removeListener('TEAMKILL', this.onTeamkill);
this.verbose(1, 'Unmounted.');
}
async onTeamkill(info) {
// TEAMKILL only fires when BOTH attacker and victim resolved, but guard anyway —
// idiomatic and harmless (see references/event-reliability.md).
if (!info.attacker || !info.victim) return;
await this.sendDiscordMessage({
embed: {
title: 'Teamkill',
color: this.options.color,
fields: [
{ name: 'Attacker', value: `${info.attacker.name} (${info.attacker.eosID})` },
{ name: 'Victim', value: `${info.victim.name} (${info.victim.eosID})` },
{ name: 'Weapon', value: info.weapon || 'Unknown' }
],
timestamp: (info.time instanceof Date ? info.time : new Date()).toISOString()
}
});
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |