Docs
Formcord
Universal Discord notifications with zero dependencies. Works in Edge, serverless, and Node runtimes using only Web APIs.
Get started
Install
bash
npm install formcordEnvironment variables
ENV
FORMCORD_DISCORD_TOKEN=xxxx
FORMCORD_DISCORD_CHANNEL=yyyyFirst message
TS
import { formcord } from "formcord";
await formcord.send({
token: process.env.FORMCORD_DISCORD_TOKEN!,
channelId: process.env.FORMCORD_DISCORD_CHANNEL!,
data: {
"Subject": "Hello",
"Email": "me@example.com",
"Message": "This is a test",
}
});Discord bot setup (quick and easy)
- Create an app and bot in the Discord Developer Portal.
- Copy the bot token.
- Invite the bot to your server with permission to send messages.
- Get the channel ID (enable Developer Mode, then copy ID).
Helpers
Built-in helpers to standardize your payloads. All custom fields should go inside the data object.
contact
Form submissions and inquiries.
- data.subject - Subject of the contact message
- data.email - Sender email address
- data.message - Message body
- text - Optional top message text
- embed - Optional embed styling
TS
formcord.contact({
token,
channelId,
throwOnError,
text,
embed,
data: {
subject,
email,
message,
}
});error
Runtime errors with optional context.
- error - Error object or message
- data.source - Where the error originated
- data.environment - Runtime environment
- text - Optional top message text
- embed - Optional embed styling
TS
formcord.error({
token,
channelId,
error,
throwOnError,
text,
embed,
data: {
source,
environment,
}
});deploy
Deployment notifications.
- data.project - Project name
- data.environment - Environment name
- data.url - Deployment URL
- data.commit - Commit SHA or ref
- text - Optional top message text
- embed - Optional embed styling
TS
formcord.deploy({
token,
channelId,
throwOnError,
text,
embed,
data: {
project,
environment,
url,
commit,
}
});feedback
User feedback and ratings.
- data.rating - Rating value
- data.message - Feedback text
- text - Optional top message text
- embed - Optional embed styling
TS
formcord.feedback({
token,
channelId,
throwOnError,
text,
embed,
data: {
rating,
message,
}
});bug
Bug reports with steps and context.
- data.title - Bug title
- data.steps - Steps to reproduce
- data.browser - Browser or client info
- text - Optional top message text
- embed - Optional embed styling
TS
formcord.bug({
token,
channelId,
throwOnError,
text,
embed,
data: {
title,
steps,
browser,
}
});Theming and custom fields
Add a top message with text, customize embeds with embed, and pass unlimited custom fields in data.
TS
formcord.contact({
token,
channelId,
text: "New support request",
embed: {
title: "RenderCard Support Message",
author: { name: "Anonymous User - 8f3a2d" },
color: 0x5865f2,
footer: { text: "System Notification" },
timestamp: new Date().toISOString(),
},
data: {
subject: "Hello",
email: "me@example.com",
message: "This is a test",
"Extra Field": "Unlimited custom fields allowed"
}
});⚠️ Migration Guide (v1 to v2)
Version 2.0.0 standardizes field names to prevent confusion between top-level text, embed styling, and form fields.
Before (v1.x)
TS
formcord.contact({
token,
channelId,
content: "Top message text",
theme: { title: "My Title" },
subject: "Hello",
email: "me@example.com",
message: "Test"
});After (v2.x)
TS
formcord.contact({
token,
channelId,
text: "Top message text",
embed: { title: "My Title" },
data: {
subject: "Hello",
email: "me@example.com",
message: "Test"
}
});Notes
- Uses only
fetch,URL, and JSON. - Retries once on 429 rate limits.
- Best effort delivery.
- Requires a Discord bot token with permission to post.
- Not a guaranteed delivery system for enterprise logging or auditing.