Skip to content

Stickman Fight Module

The Stickman Fight Module (@zumito-team/stickmanfight-module) provides a single command that pits two Discord users (or random members) against each other in an animated stick figure battle. The result is a multi-frame GIF with fight poses, particle effects, and a dramatic K.O. finish.

Terminal window
npm install @zumito-team/stickmanfight-module

Add to your zumito.config.ts:

bundles: ['@zumito-team/stickmanfight-module']

The /stickmanfight command with arguments:

ArgumentTypeRequiredDescription
user1userNoFirst fighter. Random member if omitted.
user2userNoSecond fighter. Random member if omitted.

Behavior:

  1. Validates the guild has at least 2 non-bot members.
  2. Resolves fighters: specified users or picks two random members.
  3. Randomly determines a winner.
  4. Creates a CanvasUtils instance (500×300, GIF mode, 100ms frame delay).
  5. Loads both user avatars (64×64px).
  6. Renders a ~17-frame animation sequence:
    • Intro (3 frames) — “FIGHT!” text appears.
    • Approach (4 frames) — Both stickmen walk toward center.
    • Flash (2 frames) — Combat flash effect.
    • Combat (8 frames) — Attack, defend, and hit poses alternating between fighters.
    • Pre-KO (3 frames) — The loser staggers.
    • K.O. (5 frames) — Dramatic knockout with golden particle effects and “K.O.!” text.
  7. Returns the GIF as a Discord attachment with an embed announcing the winner.

The stick figures use distinct poses for each animation phase:

PoseDescription
normalStanding pose with arms at sides.
attackOne arm extended forward (punching).
defendArms crossed in front (blocking).
hitLeaning back (taking damage).
koFallen over (defeated).

Visual effects:

  • Background — Vertical gradient (sky blue to ground brown).
  • Particles — Golden sparkle effects around the K.O. text.

The module accepts an optional configuration object:

import { StickmanfightModule } from '@zumito-team/stickmanfight-module';
new StickmanfightModule({
embedColor: 0x5865f2 // Discord embed color (hex)
});
OptionTypeDefaultDescription
embedColornumber0x5865f2Hex color for the result embed.

The command supports English and Spanish:

KeyENES
description”Make two members fight in an epic stickman battle!""Haz que dos miembros peleen en una batalla épica!”
result"The winner is **{winner}**!""El ganador es **{winner}**!"

Translation files:

  • translations/command/stickmanfight/en.json
  • translations/command/stickmanfight/es.json

The animation is defined in the Stickmanfight command class. You can extend it to create custom fights:

class CustomStickmanfight extends Stickmanfight {
async execute(params: CommandParameters) {
// Override the animation logic
const canvas = new CanvasUtils({ width: 600, height: 400, isGif: true, delay: 80 });
// ... custom animation frames ...
}
}

The private helper functions (drawStickman, drawBackground, drawParticles) are defined within the command. You can extract them for reuse:

// Reuse CanvasUtils for your own stickman animations
import { CanvasUtils } from '@zumito-team/canvas-module';
function drawStickman(canvas: CanvasUtils, x: number, y: number, avatar: Image, pose: string) {
const ctx = canvas.getContext();
// Custom stickman drawing logic
}

Extend the module source to add new combat poses, victory animations, or special effects:

  • New poses → add draw branches in the stickman rendering logic.
  • New effects → use canvas.drawParticles() for sparkle effects or add drawExplosion(), drawSmoke(), etc.
  • Arena backgrounds → replace the gradient with a loaded background image.
  • @zumito-team/canvas-module — For CanvasUtils and image loading.
  • zumito-framework
  • Canvas Module — Provides the canvas utilities used for the animation.