DiscordInteractions.Plug (discord_interactions v0.1.0)
View SourceA 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:
- Verifying security headers using Ed25519 signatures
- Handling ping interactions automatically
- 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
.