Skip to content

feat: adapt to v0#5

Closed
null8626 wants to merge 6 commits into
top-gg-community:mainfrom
null8626:split/v0
Closed

feat: adapt to v0#5
null8626 wants to merge 6 commits into
top-gg-community:mainfrom
null8626:split/v0

Conversation

@null8626
Copy link
Copy Markdown
Member

@null8626 null8626 commented Sep 16, 2025

The following pull request is a toned down version of #3. This pull request focuses solely on the
changes done to the SDK in the v0 of the API. Such as:

  • Adapting the SDK to newer changes in v0.
  • Refactoring the autoposter.
  • Refactoring the SDK by using Lua's setmetatable({}, self) to emulate OOP objects over manual copied code that emulates OOP.
  • Removing useless manual EventEmitter implementation for the autoposter.

@null8626 null8626 changed the title feat: adapt to v0 and add autoposter feat: adapt to v0 Sep 16, 2025
Copy link
Copy Markdown
Collaborator

@velddev velddev left a comment

Choose a reason for hiding this comment

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

revert the public API function names and it seems fine to me

Comment thread topgg/lib/api.lua Outdated
return res;
if data then
return data
else
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: else not really needed 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 topgg/lib/api.lua Outdated
if type(query.fields) == 'table' then
query.fields = concat(query.fields, ',');
end
function Api:get_bot(id)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

avoid renaming the public API please

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.

Working on it.

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, with the exception of Api:init(token); to local client = Api:new(token);.

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.

Full diff on the API methods:

PRIVATE METHODS:
- Api:commit(method, url, req, body)
+ Api:__commit(method, url, request, body)
+ Api:__request(method, path, body, query)

PUBLIC METHODS:
- Api:init(token)
+ Api:new(token)

- Api:getVotes()
+ Api:getVotes(page)

+ Api:newAutoposter()

Comment thread topgg/lib/api.lua Outdated
local data = self:__request('GET', string.format('/bots/check?userId=%s', id))

return self:request('GET', '/bots/votes');
return not not data.voted
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not not?

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.

In the API, voted is an integer, not a boolean. But I'll revise this to data.voted ~= 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.

@null8626
Copy link
Copy Markdown
Member Author

null8626 commented Feb 5, 2026

Closed in anticipation of a major update that adds v1 support but deletes all v0 features.

@null8626 null8626 closed this Feb 5, 2026
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.

2 participants