Skip to dossier

All Personal Projects

Innkeeper

Production

TypeScript Discord bot that fetches Magic: The Gathering cards from Scryfall and posts them in the server.

  • TypeScript
  • Discord.js
  • Axios
  • GitHub Actions
  • AWS Lightsail

Repository

Problem & Motivation

Looking up a Magic: The Gathering card mid-conversation means leaving Discord. Innkeeper keeps that lookup in the server: a member asks for a card, the bot calls Scryfall, and the card comes back in the channel. The repository is a TypeScript Discord.js bot, with Axios for the card requests.

System Architecture

Discord.js holds the gateway connection. Card fetches are HTTP GET calls to the Scryfall API through Axios. The bot token lives in .env, following .env_example, and is not committed. npm run build, npm run start, and npm run dev cover the compiled bot, the running process, and local development. A GitHub Actions workflow SSHes to an AWS Lightsail instance and runs the commands that keep the bot hosted.

flowchart LR
  member["Discord member"] --> bot["Innkeeper"]
  bot --> scryfall["Scryfall API"]
  scryfall --> bot
  bot --> channel["Discord channel"]
  actions["GitHub Actions"] --> host["AWS Lightsail"]

Key Engineering Trade-offs

  • Scryfall is the card catalog. The bot does not ship a local card database, so names, printings, and images stay current with Scryfall, and a lookup fails when Scryfall or the network does.
  • The bot is TypeScript on Discord.js, with Axios limited to the Scryfall GET. A Discord application and a bot token are required, and the token stays in the environment file.
  • Hosting is an AWS Lightsail instance, which can hold a long-running Discord gateway connection. GitHub Actions deploys over SSH, so the workflow needs that instance and SSH access to it.