interaction_server

command
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: BSD-3-Clause Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

This example runs a bot in Discord's "webhook interactions" mode: instead of keeping a gateway websocket connection open, an HTTP server receives interaction POSTs from Discord and answers them directly in the HTTP response. The bot works without any persistent connection to Discord.

Setup:

  1. Create an application in the Discord developer portal.
  2. Copy the public key from the "General Information" page into the INTERACTIONS_PUBLIC_KEY environment variable.
  3. Set DISCORD_TOKEN to a bot token. It is only used for REST calls made on top of received interactions (ReplyEphemeral below); the inline responses need no token at all.
  4. Expose the server through a public HTTPS URL (Discord requires HTTPS; use a reverse proxy or a tunnel such as ngrok for local testing) and set the "Interactions Endpoint URL" in the developer portal to https://your.host/interactions. Discord verifies the URL by sending a PING request, which the InteractionServer answers automatically.

Optionally set DISCORD_APP_ID (and DISCORD_GUILD_ID for instant guild scope) to register the two slash commands of this example on startup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL