Skip to content

feat: onyx discord bot - supervisord and kube deployment#7706

Merged
justin-tahara merged 4 commits intomainfrom
wenxi-jtahara/discord-bot-changes
Jan 23, 2026
Merged

feat: onyx discord bot - supervisord and kube deployment#7706
justin-tahara merged 4 commits intomainfrom
wenxi-jtahara/discord-bot-changes

Conversation

@justin-tahara
Copy link
Copy Markdown
Contributor

@justin-tahara justin-tahara commented Jan 23, 2026

Description

Creating all the necessary infra related to the Discord Bot.

How Has This Been Tested?

Additional Options

  • [Optional] Override Linear Check

Summary by cubic

Adds Discord bot support with supervisord and deployment configs for Docker Compose and Kubernetes. Enables a single OnyxBot instance to run in Discord and route message processing to the API server.

  • New Features

    • Supervisord program for discord_bot with logging and auto-restart.
    • Dev docs and tooling: multitenant Discord README and VSCode launch config.
    • Docker Compose envs: DISCORD_BOT_TOKEN, DISCORD_BOT_INVOKE_CHAR, API_SERVER_PROTOCOL/HOST.
    • Helm: new discordbot values (enablement, token via secret, resources, labels) and chart version bump to 0.4.20.
    • Log redirect now streams discord_bot logs.
  • Migration

    • Set DISCORD_BOT_TOKEN (required). Only one bot instance per token; do not scale workers.
    • Optionally set DISCORD_BOT_INVOKE_CHAR (default "!").
    • Ensure API_SERVER_HOST/PROTOCOL point to the reachable API service.
    • Kubernetes: set discordbot.enabled=true and provide the token (prefer a secret). Keep a single replica.

Written for commit ab807e3. Summary will update on new commits.

@justin-tahara justin-tahara requested a review from a team as a code owner January 23, 2026 20:33
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 23, 2026

Greptile Overview

Greptile Summary

Added infrastructure configuration for the Discord bot feature across Docker Compose and Kubernetes deployments. The PR adds supervisord configuration to run the Discord bot process, environment variables for bot configuration (DISCORD_BOT_TOKEN, DISCORD_BOT_INVOKE_CHAR, API_SERVER_PROTOCOL, API_SERVER_HOST), and VS Code debug configuration.

Key Changes:

  • Added discord_bot program to supervisord with logging to /var/log/discord_bot.log
  • Configured Discord bot environment variables in all Docker Compose variants with clear warnings about scaling constraints
  • Added Helm values for discordbot deployment configuration including bot token secret management
  • Bumped Helm chart version from 0.4.19 to 0.4.20

Critical Issues Found:

  • Missing Helm deployment template (deployment/helm/charts/onyx/templates/discordbot.yaml) - the values are defined but no actual Kubernetes deployment will be created
  • Missing API_SERVER_PROTOCOL and API_SERVER_HOST in Helm configMap section - these are required for the Discord bot to communicate with the API server

Confidence Score: 2/5

  • This PR is incomplete and will not function properly for Kubernetes deployments
  • The Docker Compose configuration is complete and follows existing patterns, but the Kubernetes/Helm deployment is missing critical components (deployment template and required environment variables in configMap). This means Discord bot functionality will only work in Docker Compose environments, not in Kubernetes clusters.
  • deployment/helm/charts/onyx/values.yaml requires a corresponding deployment template and additional configMap entries

Important Files Changed

Filename Overview
backend/supervisord.conf Added Discord bot supervisord process configuration with proper logging
deployment/docker_compose/env.template Documented Discord bot configuration options in environment template
deployment/helm/charts/onyx/values.yaml Added Discord bot Helm values without corresponding deployment template - incomplete implementation

Sequence Diagram

sequenceDiagram
    participant Discord as Discord Platform
    participant Bot as Discord Bot Pod
    participant API as API Server
    participant Cache as Cache Manager
    participant DB as Database
    
    Note over Bot: Deployed via supervisord<br/>(Docker Compose) or<br/>Kubernetes Deployment (Helm)
    
    Bot->>Discord: Connect with DISCORD_BOT_TOKEN
    Discord-->>Bot: WebSocket connection established
    
    Bot->>Cache: Initialize cache
    Cache->>API: Fetch registered guilds
    API->>DB: Query guild configurations
    DB-->>API: Return guild data
    API-->>Cache: Return guild configurations
    
    Discord->>Bot: User message received
    Bot->>Cache: Check if guild registered
    
    alt Guild registered
        Bot->>API: POST message via API_SERVER_HOST
        Note over Bot,API: Uses API_SERVER_PROTOCOL://API_SERVER_HOST
        API->>DB: Process message & store
        API-->>Bot: Response
        Bot->>Discord: Send response to user
    else Guild not registered
        Bot->>Discord: Ignore or prompt registration
    end
    
    loop Every CACHE_REFRESH_INTERVAL
        Bot->>Cache: Refresh guild cache
        Cache->>API: Fetch updated configurations
        API-->>Cache: Return updated data
    end
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="deployment/helm/charts/onyx/templates/discordbot.yaml">

<violation number="1" location="deployment/helm/charts/onyx/templates/discordbot.yaml:74">
P2: Avoid rendering duplicate `DISCORD_BOT_TOKEN` env vars when both `botToken` and `botTokenSecretName` are set. Use an `else if` (or mutual-exclusion validation) so only one source is emitted.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 9 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="deployment/helm/charts/onyx/values.yaml">

<violation number="1" location="deployment/helm/charts/onyx/values.yaml:707">
P1: The Helm values configuration for `discordbot` is incomplete - there's no corresponding deployment template file (`templates/discordbot.yaml`) to actually deploy the Discord bot pod in Kubernetes. This configuration block will have no effect until a deployment template is created. See `slackbot.yaml` template as a reference for the expected structure.</violation>

<violation number="2" location="deployment/helm/charts/onyx/values.yaml:1203">
P2: Do not store the Discord bot token in the ConfigMap. Tokens are secrets and should be sourced from a Kubernetes Secret (e.g., via `discordbot.botTokenSecretName`). Keeping `DISCORD_BOT_TOKEN` in the ConfigMap risks leaking the token in plain text.</violation>
</file>

<file name="deployment/docker_compose/docker-compose.multitenant-dev.yml">

<violation number="1" location="deployment/docker_compose/docker-compose.multitenant-dev.yml:227">
P3: Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use an empty default for DISCORD_BOT_INVOKE_CHAR instead.

(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.) [FEEDBACK_USED]</violation>

<violation number="2" location="deployment/docker_compose/docker-compose.multitenant-dev.yml:229">
P3: Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use empty defaults for API server connection values instead.

(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.) [FEEDBACK_USED]</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

# Discord bot for Onyx
# IMPORTANT: Discord bots cannot be horizontally scaled - only one WebSocket connection per token is allowed.
# The bot offloads message processing to scalable API pods via HTTP requests.
discordbot:
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The Helm values configuration for discordbot is incomplete - there's no corresponding deployment template file (templates/discordbot.yaml) to actually deploy the Discord bot pod in Kubernetes. This configuration block will have no effect until a deployment template is created. See slackbot.yaml template as a reference for the expected structure.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At deployment/helm/charts/onyx/values.yaml, line 707:

<comment>The Helm values configuration for `discordbot` is incomplete - there's no corresponding deployment template file (`templates/discordbot.yaml`) to actually deploy the Discord bot pod in Kubernetes. This configuration block will have no effect until a deployment template is created. See `slackbot.yaml` template as a reference for the expected structure.</comment>

<file context>
@@ -701,6 +701,45 @@ celery_worker_user_file_processing:
+# Discord bot for Onyx
+# IMPORTANT: Discord bots cannot be horizontally scaled - only one WebSocket connection per token is allowed.
+# The bot offloads message processing to scalable API pods via HTTP requests.
+discordbot:
+  enabled: false  # Disabled by default - requires bot token configuration
+  # Bot token can be provided directly or via a Kubernetes secret
</file context>
Fix with Cubic

NOTIFY_SLACKBOT_NO_ANSWER: ""
# Discord Bot Configs (runs via supervisord, requires DISCORD_BOT_TOKEN to be set)
# IMPORTANT: Only one Discord bot instance can run per token
DISCORD_BOT_TOKEN: ""
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Do not store the Discord bot token in the ConfigMap. Tokens are secrets and should be sourced from a Kubernetes Secret (e.g., via discordbot.botTokenSecretName). Keeping DISCORD_BOT_TOKEN in the ConfigMap risks leaking the token in plain text.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At deployment/helm/charts/onyx/values.yaml, line 1203:

<comment>Do not store the Discord bot token in the ConfigMap. Tokens are secrets and should be sourced from a Kubernetes Secret (e.g., via `discordbot.botTokenSecretName`). Keeping `DISCORD_BOT_TOKEN` in the ConfigMap risks leaking the token in plain text.</comment>

<file context>
@@ -1159,6 +1198,10 @@ configMap:
   NOTIFY_SLACKBOT_NO_ANSWER: ""
+  # Discord Bot Configs (runs via supervisord, requires DISCORD_BOT_TOKEN to be set)
+  # IMPORTANT: Only one Discord bot instance can run per token
+  DISCORD_BOT_TOKEN: ""
+  DISCORD_BOT_INVOKE_CHAR: ""
   # Logging
</file context>
Fix with Cubic

# Discord Bot Configuration (runs via supervisord, requires DISCORD_BOT_TOKEN to be set)
# IMPORTANT: Only one Discord bot instance can run per token - do not scale background workers
- DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-}
- DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!}
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use an empty default for DISCORD_BOT_INVOKE_CHAR instead.

(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At deployment/docker_compose/docker-compose.multitenant-dev.yml, line 227:

<comment>Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use an empty default for DISCORD_BOT_INVOKE_CHAR instead.

(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.) </comment>

<file context>
@@ -221,6 +221,13 @@ services:
+      # Discord Bot Configuration (runs via supervisord, requires DISCORD_BOT_TOKEN to be set)
+      # IMPORTANT: Only one Discord bot instance can run per token - do not scale background workers
+      - DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-}
+      - DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!}
+      # API Server connection for Discord bot message processing
+      - API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-http}
</file context>
Suggested change
- DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!}
- DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-}
Fix with Cubic

- DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-}
- DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!}
# API Server connection for Discord bot message processing
- API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-http}
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use empty defaults for API server connection values instead.

(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At deployment/docker_compose/docker-compose.multitenant-dev.yml, line 229:

<comment>Avoid hardcoded defaults for env configs so missing values are surfaced and guards can trigger. Use empty defaults for API server connection values instead.

(Based on your team's feedback about avoiding truthy/hardcoded defaults in env configs.) </comment>

<file context>
@@ -221,6 +221,13 @@ services:
+      - DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-}
+      - DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!}
+      # API Server connection for Discord bot message processing
+      - API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-http}
+      - API_SERVER_HOST=${API_SERVER_HOST:-api_server}
       # Logging
</file context>
Suggested change
- API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-http}
- API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-}
Fix with Cubic

@justin-tahara justin-tahara added this pull request to the merge queue Jan 23, 2026
Merged via the queue into main with commit 52a312a Jan 23, 2026
77 checks passed
@justin-tahara justin-tahara deleted the wenxi-jtahara/discord-bot-changes branch January 23, 2026 20:58
@wenxi-onyx wenxi-onyx mentioned this pull request Jan 26, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants