Skip to content

Hans-Vader/squadjs-plugin-creator-skill

creating-squadjs-plugins

Verified

Use 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.

templates/discord-plugin.js

View on GitHub
import 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()
      }
    });
  }
}
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall