dotnet-sdk icon indicating copy to clipboard operation
dotnet-sdk copied to clipboard

feat: add webhooks

Open null8626 opened this issue 5 months ago • 3 comments

The following pull request is a toned down version of #29. This pull request focuses solely on adding a webhooks wrapper for ASP.NET Core/Blazor.

null8626 avatar Sep 16 '25 15:09 null8626

This is not how a ASP.NET Core webhook endpoint should look like. Prefer using the minimal API to create a route at build-time. This will let the internal ASP.NET core router handle all of the actual context.

public static class RoutingExtension {
  public static void UseVoteWebhook(IRouteEndpointBuilder router, string path, ...) {
    router.MapGet(path, (req) => {
      ...
    });  
  }
}

velddev avatar Sep 17 '25 12:09 velddev

Will work on it.

null8626 avatar Sep 17 '25 12:09 null8626

Done. Made it more similar to Node.js SDK' webhooks wrapper.

Example usage:

using DiscordBotsList.Api.Webhooks;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

var webhooks = new Webhooks("my webhook secret");

app.MapPost("/webhooks", webhooks.Listener((context, vote) =>
{
    Console.WriteLine($"A user with the ID of {vote.VoterId} has voted us on Top.gg!");

    return Task.CompletedTask;
}));

app.Run();

null8626 avatar Sep 18 '25 10:09 null8626

looks good to me

williamdevgg avatar Feb 05 '26 19:02 williamdevgg

Most of this wouldn't work with the actual api. Refer to the docs here for more information.

https://docs.top.gg/docs/API/v1/webhooks/ https://docs.top.gg/docs/API/v1/integrations

So sorry! I was too fixated on top-gg/webhooks-v2-nodejs-example that I didn't notice the new webhook events. My bad. I've addressed them now.

null8626 avatar Feb 17 '26 10:02 null8626