openclaw - ✅(Solved) Fix Discord /new slash command times out - needs deferReply() [1 pull requests, 5 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58602Fetched 2026-04-08 02:00:18
View on GitHub
Comments
5
Participants
2
Timeline
11
Reactions
0
Timeline (top)
commented ×5mentioned ×3subscribed ×3

Root Cause

The Discord interaction handler needs to call interaction.deferReply() within 3 seconds, then do the session reset work asynchronously, then send the final response via interaction.editReply(). Currently it appears to do the work synchronously before responding.

Fix Action

Fix / Workaround

  • OpenClaw 2026.3.28 (f9b1079)
  • Discord bot in guild channel (not DM)
  • No auth issues -- commands.allowFrom is not set, guild config has no user restrictions
  • The /new text command also does not work as a workaround since Discord intercepts / as slash command UI

Users cannot reset sessions from Discord. The only workaround is... there is no workaround. The CLI openclaw message send sends as the bot (not authorized for commands), and AppleScript keystrokes get intercepted by Discord slash command autocomplete.

PR fix notes

PR #1: Add GitHub App, Discord bot, SQLite persistence, and test suite

Description (problem / solution / changelog)

Expand the deployment server from a simple edge-function deployer into a full deployment management hub:

  • Refactor monolithic src/index.ts into modular architecture (deploy/, discord/, github/, auth/, db/, coolify/)
  • Add SQLite persistence via better-sqlite3 for tracking deployments, user links (Discord<->GitHub via GHID), permissions, and settings
  • Add Discord bot (discord.js v14) with slash commands: /previews (list, status, teardown, reset-db), /preview-permissions, /deploy-config, /link-github, /admin
  • Add GitHub App webhook receiver (@octokit/webhooks) for PR lifecycle tracking and auto-cleanup on PR close
  • Add GitHub OAuth flow for linking Discord accounts to GitHub
  • Add deployment reporting endpoint (POST /deployments/:name/report) called by the GitHub Action after deployment completes
  • Add retention sweep for auto-cleanup of stale preview deployments
  • Add Discord deployment announcement embeds
  • Add comprehensive test suite (117 tests across 11 suites) with mocks for Coolify API, Discord.js, GitHub webhooks, and in-memory SQLite
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

Summary by CodeRabbit

  • New Features
    • Preview deployment management via Discord slash commands (list, status, approve, teardown, reset database)
    • GitHub account linking for Discord users via OAuth
    • Automatic deployment cleanup with configurable retention policies
    • Deployment approval workflow integration with GitHub
    • Discord notifications for deployment lifecycle events
    • Repository and role-based permission controls for deployments
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Changed files

  • .claude/projects/-home-jon-coolify-supabase-deployment-server/memory/MEMORY.md (added, +3/-0)
  • .claude/projects/-home-jon-coolify-supabase-deployment-server/memory/project_system_overview.md (added, +15/-0)
  • .claude/projects/-home-jon-coolify-supabase-deployment-server/memory/reference_related_repos.md (added, +10/-0)
  • .claude/projects/-home-jon-coolify-supabase-deployment-server/memory/user_role.md (added, +12/-0)
  • .gitignore (modified, +3/-0)
  • ARCHITECTURE.md (added, +170/-0)
  • CLAUDE.md (added, +185/-0)
  • jest.config.cjs (added, +23/-0)
  • package-lock.json (modified, +7950/-653)
  • package.json (modified, +16/-2)
  • src/__tests__/auth/oauth.test.ts (added, +132/-0)
  • src/__tests__/coolify/operations.test.ts (added, +175/-0)
  • src/__tests__/db/repositories.test.ts (added, +291/-0)
  • src/__tests__/deploy/auth.test.ts (added, +75/-0)
  • src/__tests__/deploy/retention.test.ts (added, +105/-0)
  • src/__tests__/deploy/router.test.ts (added, +196/-0)
  • src/__tests__/discord/commands.test.ts (added, +366/-0)
  • src/__tests__/discord/notifications.test.ts (added, +156/-0)
  • src/__tests__/github/approval.test.ts (added, +220/-0)
  • src/__tests__/github/deployment-gates.test.ts (added, +76/-0)
  • src/__tests__/github/pull-request.test.ts (added, +164/-0)
  • src/__tests__/github/push.test.ts (added, +72/-0)
  • src/__tests__/github/router.test.ts (added, +146/-0)
  • src/__tests__/mocks/config.ts (added, +23/-0)
  • src/__tests__/mocks/coolify-client.ts (added, +79/-0)
  • src/__tests__/mocks/db.ts (added, +45/-0)
  • src/__tests__/mocks/discord.ts (added, +90/-0)
  • src/__tests__/mocks/octokit-app.ts (added, +27/-0)
  • src/__tests__/mocks/octokit-webhooks.ts (added, +42/-0)
  • src/auth/router.ts (added, +128/-0)
  • src/config.ts (added, +41/-0)
  • src/coolify/operations.ts (added, +129/-0)
  • src/db/client.ts (added, +23/-0)
  • src/db/repositories/deployments.ts (added, +232/-0)
  • src/db/repositories/permissions.ts (added, +52/-0)
  • src/db/repositories/settings.ts (added, +31/-0)
  • src/db/repositories/users.ts (added, +51/-0)
  • src/db/schema.ts (added, +66/-0)
  • src/deploy/auth.ts (added, +73/-0)
  • src/deploy/retention.ts (added, +55/-0)
  • src/deploy/router.ts (added, +262/-0)
  • src/deploy/service.ts (added, +66/-0)
  • src/deploy/tunnel.ts (added, +196/-0)
  • src/discord/bot.ts (added, +84/-0)
  • src/discord/commands/admin.ts (added, +58/-0)
  • src/discord/commands/deploy-config.ts (added, +88/-0)
  • src/discord/commands/index.ts (added, +208/-0)
  • src/discord/commands/link-github.ts (added, +58/-0)
  • src/discord/commands/permissions.ts (added, +76/-0)
  • src/discord/commands/previews.ts (added, +372/-0)
  • src/discord/notifications.ts (added, +196/-0)
  • src/github/app.ts (added, +45/-0)
  • src/github/approval-policy.ts (added, +42/-0)
  • src/github/deployment-gates.ts (added, +152/-0)
  • src/github/handlers/deployment-protection-rule.ts (added, +217/-0)
  • src/github/handlers/pull-request.ts (added, +134/-0)
  • src/github/handlers/push.ts (added, +17/-0)
  • src/github/router.ts (added, +61/-0)
  • src/index.ts (modified, +30/-491)
  • src/shared/validation.ts (added, +11/-0)
  • tsconfig.jest.json (added, +10/-0)
  • tsconfig.json (modified, +11/-4)

Code Example

await interaction.deferReply({ flags: MessageFlags.Ephemeral });
// ... do session reset work ...
await interaction.editReply({ content: "✅ New session started" });
RAW_BUFFERClick to expand / collapse

Problem

The /new slash command in Discord consistently fails with "application did not respond in time." This is the Discord 3-second interaction timeout -- the gateway takes longer than 3 seconds to process the session reset and Discord gives up before getting a response.

Expected Behavior

/new should reset the session and respond with "✅ New session started" (which it does in other contexts like DMs where timing is less strict).

Actual Behavior

Discord shows: "application did not respond in time" every time /new is used in guild channels.

Root Cause

The Discord interaction handler needs to call interaction.deferReply() within 3 seconds, then do the session reset work asynchronously, then send the final response via interaction.editReply(). Currently it appears to do the work synchronously before responding.

Environment

  • OpenClaw 2026.3.28 (f9b1079)
  • Discord bot in guild channel (not DM)
  • No auth issues -- commands.allowFrom is not set, guild config has no user restrictions
  • The /new text command also does not work as a workaround since Discord intercepts / as slash command UI

Impact

Users cannot reset sessions from Discord. The only workaround is... there is no workaround. The CLI openclaw message send sends as the bot (not authorized for commands), and AppleScript keystrokes get intercepted by Discord slash command autocomplete.

Suggested Fix

In the Discord slash command handler for /new:

await interaction.deferReply({ flags: MessageFlags.Ephemeral });
// ... do session reset work ...
await interaction.editReply({ content: "✅ New session started" });

extent analysis

TL;DR

Modify the Discord slash command handler for /new to defer the reply and perform session reset work asynchronously.

Guidance

  • Verify the current implementation of the /new slash command handler to ensure it is not already deferring the reply.
  • Update the handler to call interaction.deferReply() within 3 seconds of receiving the interaction.
  • Perform the session reset work asynchronously after deferring the reply.
  • Use interaction.editReply() to send the final response after the session reset work is complete.

Example

await interaction.deferReply({ flags: MessageFlags.Ephemeral });
// ... do session reset work ...
await interaction.editReply({ content: "✅ New session started" });

Notes

This solution assumes that the session reset work is the cause of the timeout and that deferring the reply will allow the work to be completed within the allotted time.

Recommendation

Apply workaround: Modify the Discord slash command handler for /new to defer the reply and perform session reset work asynchronously, as this will allow the bot to respond within the 3-second timeout and complete the session reset work without interrupting the user interaction.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING