Webhooks
Receive real-time vote notifications via webhook.
Vote webhooks are fired whenever a user upvotes your bot on DiscordForge. Configure your webhook URL in your bot's edit page on the Dashboard.
Webhook Payload
When a user votes, DiscordForge sends a POST request to your configured webhook URL with the following body:
1{2 "admin": false,3 "avatar": "https:__TOKEN_ID_0_END__4 "username": "CoolUser",5 "id": "123456789012345678",6 "weeklyVotes": 3,7 "totalVotes": 42,8 "isTest": false9}Headers
The request includes your webhook secret as an Authorization header so you can verify it's from DiscordForge:
1Authorization: <YOUR_WEBHOOK_SECRET>SDK Usage with Express
webhook-server.ts
1import express from "express";2 3const app = express();4app.use(express.json());5 6const WEBHOOK_SECRET = process.env.FORGE_WEBHOOK_SECRET;7 8app.post("/webhook/vote", (req, res) => {9 // Verify the request is from DiscordForge10 if (req.headers.authorization !== WEBHOOK_SECRET) {11 return res.status(401).json({ error: "Unauthorized" });12 }13 14 const { id, username, weeklyVotes, totalVotes, isTest } = req.body;15 16 if (isTest) {17 console.log("Test webhook received!");18 return res.status(200).json({ ok: true });19 }20 21 console.log(`${username} (${id}) voted!`);22 console.log(`Weekly: ${weeklyVotes} | Total: ${totalVotes}`);23 24 // Reward the user in your bot25 // grantPremiumFeatures(id);26 27 res.status(200).json({ ok: true });28});29 30app.listen(3000, () => {31 console.log("Webhook server running on port 3000");32});Testing
Use the Test Webhook button in your bot's edit page to send a test payload. Test payloads have isTest: true.
