Dotnet Library

The community-maintained .NET library for Top.gg. If you experience any issues, please submit an issue on GitHub.

Installation

Nuget

If you're using Nuget you can use and/or find it with the ID DiscordBotsList.Api or use:

Install-Package DiscordBotsList.Api

Usage

Unauthorized API Usage

This section covers the usage of the API without an authorization token.

Setting Up

DiscordBotListApi DblApi = new DiscordBotListApi();

Get Bots

IBot bot = DblApi.GetBotAsync(BOTID); // Replace BOTID with the bot's ID

Get User

IUser bot = DblApi.GetUserAsync(USERID); // Replace USERID with the user's ID

Authorized API Usage

This section covers the usage of the API with an authorization token.

Setting Up

AuthDiscordBotListApi DblApi = new AuthDiscordBotListApi(BOTID, AUTHTOKEN);

Updating Stats

ISelfBot me = await DblApi.GetMeAsync();
await me.UpdateStatsAsync(
  // indexShard
  24,
  // shardCount
  50,
  // shards
  new[] { 12, 421, 62, 241, 524, 534 }
);

// Update stats           guildCount
await me.UpdateStatsAsync(2133);

Widgets

string widgetUrl = new SmallWidgetOptions()
	.SetType(WidgetType.OWNER)
	.SetLeftColor(255, 255, 255)
	.Build(160105994217586689);

Generates the following:

Discord Bots