Star Kitten

Star Kitten is a framework for building bots for EVE Online.

This repository contains multiple bots and the framework library itself.

Packages

packages/lib

The Star Kitten library.

packages/star-kitten-bot

The Star Kitten bot. A multi-functional Discord bot for EVE online.

packages/concierge-bot

Concierge Freight bot. A bot to support Concierge Freight corporation in it's hauling services.

Installation & Running the bots

Requirements

  • This bot and framework is built to run on Bun and utilizes bun unique apis.

1. Create an EVE application

Each bot will need a unique EVE third-party application configured. Create a new eve third-party application or get the details from one of your existing Applications. It is a good idea to have an application for development and production use as they will likely require unique callback urls.

2. Create a Discord application & bot token

You will need to Create a Discord application and enable a Bot for that application. It's best to create at least two applications, one for development and one for production so that you can build and test features without disrupting the live production bot application.

3. Install the Discord bot on your server / user

The simplest way to add a bot is to use the Discord Provided Link which uses your Discord application client id.

https://discord.com/oauth2/authorize?client_id=<YOUR DISCORD CLIENT ID>

4. Installing the library

If you are creating your own bot outside this repository, install the @star-kitten/lib package in your project.

This framework is publised to my private npm repository, so add the registry to your npm config

npm config set @star-kitten:registry=https://git.f302.me/api/packages/jb/npm/

Then install the library

bun add @star-kitten/lib

5. Create .env files (Optional)

Using a .env file is not required if you're creating your own bot using @star-kitten/lib. You can provide the values as options to the createBot() function for most of these environment variables. However, if you plan to run my bots, they are set up to use these environment variables.

I use dotenvx to manage my .env files securely which allows me to commit the .env.development and .env.production to my git. However, unless I give you my .env.keys file these are useless to you. So, create your own .env files to replace mine and fill out the environment variables with your unqiue tokens and secrets.

The environment variable names are not encrypted, so you can use them as a reference if this is out of date. But here's an example with some descriptions:

# DISCORD_BOT_TOKEN - Your Discord Bot token
DISCORD_BOT_TOKEN=""

# EVE_CLIENT_ID - The EVE application client id. (required to interact with authenticated ESI endpoints)
EVE_CLIENT_ID=""

# EVE_CLIENT_SECRET - The EVE application client secret. (required to interact with authenticated ESI endpoints)
EVE_CLIENT_SECRET=""

# ESI_USER_AGENT - Used to provide some details here so that CCP can contact you if needed.
ESI_USER_AGENT=""

# EVE_CALLBACK_URL - The EVE application callback url you've set up to handle authentication OAuth2 callbacks.
EVE_CALLBACK_URL="https://mysite.com/callback"

# NODE_ENV - defaults to "development", set to "production" for better performance
NODE_ENV="production"

# PORT - the port used for any web server, default: 3000
PORT="3000"

# LOG_LEVEL - The level of logs that will be written to the console. default: "debug" if NODE_ENV="development", otherwise "info"
LOG_LEVEL="info"

# STAR_KITTEN_KV_DB_PATH - The file path for the sqlite used for star kitten core kv functionality. This handles command interaction resumability,
# caching, and more. If not set, uses an in-memory db so command interactions will not work across bot restarts.
STAR_KITTEN_KV_DB_PATH=""

# CONCIERGE_DB_PATH - The db file path for the sqlite used within concierge bot. default: :memory: (in-memory sqlite)
CONCIERGE_DB_PATH=""

# AUTH_DB_PATH - The db file path for the sqlite used within the library for authentication. default: path.join(process.cwd() '../../db/kitten.db')
AUTH_DB_PATH="/var/lib/litefs/auth.db"

# JANICE_KEY - If you have a janice api key to use the janice api.
JANICE_KEY=""

6. Create a bot

Set up the environment variables as described below and create a couple files like below in your project.

src/time.command.ts

import {
  type ExecutableInteraction,
  type CommandContext,
  type ChatCommandDefinition,
} from "@star-kitten/lib/discord";

const definition: ChatCommandDefinition = {
  name: "time",
  description: "Get the current EVE time",
};

async function execute(
  interaction: ExecutableInteraction,
  ctx: CommandContext
) {
  if (!interaction.isApplicationCommand()) return;

  const now = new Date();
  const eveTime = now.toISOString().split("T")[1].split(".")[0];
  const eveDate = now.toLocaleDateString(interaction.locale, {
    timeZone: "UTC",
    year: "numeric",
    month: "long",
    day: "2-digit",
    weekday: "long",
  });

  interaction.createJSXMessage(
    <container>
      <text>
        {`### ${eveTimeText[interaction.locale] || eveTimeText[Locale.EN_US]}
${eveTime}
${eveDate}`}
      </text>
    </container>
  );
}

export default {
  definition,
  execute,
};

src/main.ts

import { createBot } from "@star-kitten/lib";

createBot();

Run the bot

bunx dotenvx run -f .env.development -- bun --watch src/main.ts

Test the command

In your Discord where the bot has access run the command /time and you should see a response with the current EVE time.

6. Developing Star Kitten lib or bots

Clone this repository and install dependencies.

git clone https://git.f302.me/jb/star-kitten.git
cd star-kitten
bun i

Run Star Kitten bot in development mode

bun sk-dev

Run Concierge bot in development mode

bun co-dev
Description
Discord Bot framework for EVE Online
Readme 3.5 MiB
Languages
TypeScript 100%