Files
docs/src/content/docs/projects/chibika.md
T
naomi f8f787bde9
Node.js CI / Lint and Test (push) Successful in 1m56s
feat: time for another audit/overhaul/revamp (#13)
### Explanation

_No response_

### Issue

Closes #11

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #13
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2025-11-13 21:59:23 -08:00

6.9 KiB

title
title
Chibika

Chibika (hereinafter the "Application") is a Discord bot that provides ASCII art on demand. The Application offers curated collections of ASCII art in categories such as anime and cats, along with emoji ASCII art, delivered through Discord's slash command interface with subscription-based access control.

1. User Documentation

This section is for those interacting with a live instance of the Application.

Getting Started

  1. Add Chibika to Your Discord Server: Use the Discord OAuth2 authorisation link to add Chibika to your Discord server.

  2. Purchase Server Subscription: To use Chibika's features, you must purchase a server subscription through Discord's built-in store system.

Available Commands

/about

Displays information about Chibika, including:

  • What the bot does
  • How to get started with server subscriptions
  • Support and help resources
  • Links to Discord server for assistance

/ascii [category]

Retrieves random ASCII art from the specified category:

  • anime: Anime-themed ASCII art
  • cats: Cat-themed ASCII art

Usage: /ascii category:anime or /ascii category:cats

/emoji

Retrieves random emoji-based ASCII art from the emoji collection.

Features

  • Random Art Selection: Each command returns a randomly selected piece from the respective collection
  • Subscription-Based Access: Commands require an active Discord server subscription
  • Interactive Components: Art is displayed using Discord's modern component system
  • Error Handling: Graceful error messages for invalid inputs or system issues

Support

If you encounter issues or need assistance:

2. Technical Documentation

This section is for those interested in running their own instance of the Application.

Architecture

Chibika is built using:

  • Discord.js v14.21.0: Discord API integration
  • Fastify v5.4.0: Web server for health monitoring
  • TypeScript: Type-safe development
  • Node.js: Runtime environment

Project Structure

src/
├── assets/          # ASCII art collections
│   ├── anime.ts     # Anime ASCII art data
│   ├── cats.ts      # Cat ASCII art data
│   └── emoji.ts     # Emoji ASCII art data
├── commands/        # Discord slash commands
│   ├── about.ts     # About command handler
│   ├── ascii.ts     # ASCII art command handler
│   └── emoji.ts     # Emoji command handler
├── config/          # Configuration files
│   └── entitlements.ts # Guild entitlement configuration
├── events/          # Discord event handlers
│   └── interactionCreate.ts # Command interaction handling
├── interfaces/      # TypeScript interfaces
│   ├── ascii.ts     # ASCII art data structure
│   └── command.ts   # Command handler interface
├── modules/         # Utility modules
│   ├── getArtComponents.ts # Discord component generation
│   └── sendUnentitledResponse.ts # Subscription check responses
├── server/          # Web server
│   └── serve.ts     # Health monitoring server
├── utils/           # Utility functions
│   ├── checkEntitlement.ts # Subscription verification
│   ├── errorHandler.ts # Error handling
│   ├── getRandomValue.ts # Random selection utility
│   └── logger.ts    # Logging utility
└── index.ts         # Application entry point

Installation and Setup

  1. Prerequisites:

    • Node.js (compatible with package manager pnpm@10.13.1)
    • Discord Bot Token
    • Discord Application with appropriate permissions
  2. Installation:

    pnpm install
    
  3. Environment Configuration: Create a prod.env file with:

    DISCORD_TOKEN=your_discord_bot_token_here
    
  4. Build:

    pnpm run build
    
  5. Start:

    pnpm start
    

Development

  • Linting: pnpm run lint (ESLint with @nhcarrigan/eslint-config)
  • Testing: pnpm run test (Vitest)
  • TypeScript: Configured with @nhcarrigan/typescript-config

Key Components

Entitlement System

  • Subscription verification through Discord's entitlement API (src/utils/checkEntitlement.ts:16)
  • Fallback to hardcoded entitled guilds (src/config/entitlements.ts)
  • Un-entitled users receive subscription prompts (src/modules/sendUnentitledResponse.ts)

ASCII Art Management

  • Structured data format with text and author fields (src/interfaces/ascii.ts:7)
  • Category-based organisation (anime, cats, emoji)
  • Random selection utility (src/utils/getRandomValue.ts)

Web Server

  • Health monitoring server on port 5018 (src/server/serve.ts:65)
  • Static HTML page with bot information and links
  • Integration with nhcarrigan.com ecosystem

This section is for expansions to our legal policies specific to the Application.

Licensing

  • Source code licensed under Naomi's Public Licence
  • Copyright held by Naomi Carrigan (@nhcarrigan)

Terms and Privacy

Security

  • Security guidelines and reporting procedures outlined in SECURITY.md
  • Responsible disclosure encouraged through the #bug-reports forum channel on our Discord community

4. Contributing Documentation

This section is for documentation related to contributing to the Application's codebase.

Contributing Guidelines

Code Standards

  • ESLint Configuration: @nhcarrigan/eslint-config v5.2.0
  • TypeScript: Strict configuration via @nhcarrigan/typescript-config v4.0.0
  • Testing: Vitest for unit testing
  • Code Style: Enforced through automated linting with zero warnings policy

Development Workflow

  1. Fork the repository
  2. Create feature branch
  3. Make changes following code standards
  4. Run tests and linting: pnpm run test && pnpm run lint
  5. Build successfully: pnpm run build
  6. Submit pull request

Issue Reporting

  • Bug reports and feature requests via GitHub Issues (external project)
  • Security issues through responsible disclosure (see SECURITY.md)

Community

  • Discord Server for real-time discussion
  • Code of Conduct available at repository root

Architecture Decisions

  • Discord.js v14 for modern Discord API features
  • TypeScript for type safety and developer experience
  • Fastify for lightweight web server functionality
  • Component-based Discord interactions for enhanced user experience
  • Subscription-based access model through Discord's monetization features