Skip to content

feat: adapt to v1 - #33

Open
null8626 wants to merge 62 commits into
top-gg-community:masterfrom
null8626:split/v1
Open

feat: adapt to v1#33
null8626 wants to merge 62 commits into
top-gg-community:masterfrom
null8626:split/v1

Conversation

@null8626

@null8626 null8626 commented Oct 2, 2025

Copy link
Copy Markdown
Member

Closes #28

The following pull request is a toned down version of #29. This pull request focuses solely on adding support for v1, like posting bot commands, getting vote information, and widgets.

Other than that, it also adds error handling for invalid status codes by using response.EnsureSuccessStatusCode().

This pull request depends on #32. It has been tested.

@null8626 null8626 changed the title Split/v1 feat: adapt to v1 Oct 2, 2025
@null8626
null8626 force-pushed the split/v1 branch 4 times, most recently from fe4d82f to cf0b1f4 Compare October 3, 2025 16:42
@null8626

null8626 commented Oct 3, 2025

Copy link
Copy Markdown
Member Author

README updated.

@null8626
null8626 force-pushed the split/v1 branch 3 times, most recently from 6f81889 to a36bd10 Compare October 10, 2025 06:47
@williamdevgg

Copy link
Copy Markdown

looks good to me

@velddev velddev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good, some comment to standardize it a bit more to C# defaults 👍

Comment thread DiscordBotsList.Api/Data/Project.cs Outdated
namespace DiscordBotsList.Api.Data
{
/// <summary>
/// A project's platform.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit; you don't need the indentation in docstrings here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread DiscordBotsList.Api/Data/Project.cs Outdated
Comment on lines +20 to +36
internal class PlatformConverter : JsonConverter<Platform>
{
public override Platform Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.String)
{
switch (reader.GetString())
{
case "discord": return Platform.Discord;
}
}

throw new InvalidOperationException();
}

public override void Write(Utf8JsonWriter writer, Platform platform, JsonSerializerOptions options) => throw new InvalidOperationException();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread DiscordBotsList.Api/Data/Project.cs Outdated
Comment on lines +41 to +45
public enum ProjectType
{
DiscordBot,
DiscordServer
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These do not mean "Discord" that's what platform is for. You could have a Slack bot or a Guilded Server.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread DiscordBotsList.Api/Data/Project.cs Outdated
Comment on lines +50 to +67
internal class ProjectTypeConverter : JsonConverter<ProjectType>
{
public override ProjectType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.String)
{
switch (reader.GetString())
{
case "bot": return ProjectType.DiscordBot;
case "server": return ProjectType.DiscordServer;
}
}

throw new InvalidOperationException();
}

public override void Write(Utf8JsonWriter writer, ProjectType type, JsonSerializerOptions options) => throw new InvalidOperationException();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above; use enum converter

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread DiscordBotsList.Api/Data/Project.cs Outdated
/// <summary>
/// The project's total vote count.
/// </summary>
[JsonPropertyName("votes_total")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of naming all these you can set the jsonSerializerSettings to use a snakeCase Casing. https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonnamingpolicy?view=net-10.0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

using System.Text.Json.Serialization;

namespace DiscordBotsList.Api.Internal
namespace DiscordBotsList.Api.Serialization

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a breaking change, could we rename it to Topgg.Api.XYZ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I'm renaming the API wrapper to Topgg.Sdk.Api and the Webhooks library to Topgg.Sdk.Webhooks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants