discord-form-webhook
v1.0.2
Published
Send HTML form data to Discord webhooks with support for embeds.
Readme
discord-form-webhook
Simple JavaScript package to send HTML form data to Discord webhooks. Made by Tonie
NPM Download discord-webhook-sender
Install
npm install discord-form-webhookBasic Usage
import { sendDiscordForm } from "discord-form-webhook";
sendDiscordForm({
formSelector: "#myForm",
webhookURL: "YOUR_WEBHOOK_URL"
});Embed Mode
sendDiscordForm({
formSelector: "#myForm",
webhookURL: "YOUR_WEBHOOK_URL",
embed: true,
title: "New Submission",
desc: "Form Data",
footer: "My Site"
});Plain Text Mode
sendDiscordForm({
formSelector: "#myForm",
webhookURL: "YOUR_WEBHOOK_URL",
embed: false
});What gets sent
All form inputs are automatically collected:
<input name="username">
<input name="email">
<textarea name="message"></textarea>Becomes:
**username**: John
**email**: [email protected]
**message**: HelloOptions
| Option | Type | Description | |--------------|--------|-------------| | formSelector | string | CSS selector for the form | | webhookURL | string | Discord webhook URL | | embed | boolean | Enable embed mode | | title | string | Embed title (required if embed = true) | | desc | string | Embed description | | footer | string | Embed footer text | | content | string | Override plain text output |
Requirements
- Must run in browser
- Valid Discord webhook URL
- Inputs must have
nameattributes
Example Form
<form id="myForm">
<input name="username" placeholder="Username">
<input name="email" placeholder="Email">
<textarea name="message"></textarea>
<button type="submit">Send</button>
</form>Notes
- Auto prevents page refresh
- Sends on submit
- No backend required
- Works with Discord webhooks only
Contributing
Pull requests are welcome. You can improve validation, embeds, or add new features.
