DiscordInteractions.Plug (discord_interactions v0.1.0)

View Source

A Plug for handling Discord interaction webhooks.

This plug serves as the entry point for Discord interaction requests and implements the complete Discord Interactions API webhook flow, including:

  1. Verifying security headers using Ed25519 signatures
  2. Handling ping interactions automatically
  3. Routing command, component, and modal interactions to your handler functions

Usage

Add this plug to your Phoenix router to handle Discord interaction webhooks:

# In your router.ex file
defmodule YourAppWeb.Router do
  use YourAppWeb, :router

  # Other routes...

  # Route for Discord interactions
  forward "/discord", DiscordInteractions.Plug, YourApp.Discord
end

Where YourApp.Discord is a module that uses DiscordInteractions and defines your interaction handlers.

Summary

Functions

Callback implementation for Plug.call/2.

Callback implementation for Plug.init/1.

Functions

call(conn, opts)

Callback implementation for Plug.call/2.

init(opts)

Callback implementation for Plug.init/1.