Create a new webhook client instance
Optional
authorization: stringWebhook authorization to verify requests
Listening function for handling webhook requests
Vote handling function, this function can also throw an error to allow for the webhook to resend from Top.gg
Optional
req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>Optional
res: Response<any, Record<string, any>>Optional
next: NextFunctionAn express request handler
app.post("/webhook", wh.listener((vote) => {
console.log(vote.user); // => 395526710101278721
}));
// Throwing an error to resend the webhook
app.post("/webhook/", wh.listener((vote) => {
// for example, if your bot is offline, you should probably not handle votes and try again
if (bot.offline) throw new Error('Bot offline');
}));
Middleware function to pass to express, sets req.vote to the payload
Use the new .listener() function
app.post("/dblwebhook", wh.middleware(), (req, res) => {
// req.vote is your payload e.g
console.log(req.vote.user); // => 395526710101278721
});
Generated using TypeDoc
Top.gg Webhook
Example
Link
Webhook Data Schema
Link
Webhook Documentation