22
33The community-maintained PHP library for Top.gg.
44
5+ ## Chapters
6+
7+ - [ Installation] ( #installation )
8+ - [ Setting up] ( #setting-up )
9+ - [ Usage] ( #usage )
10+ - [ API v1] ( #api-v1 )
11+ - [ Getting your project's vote information of a user] ( #getting-your-projects-vote-information-of-a-user )
12+ - [ Posting your bot's application commands list] ( #posting-your-bots-application-commands-list )
13+ - [ API v0] ( #api-v0 )
14+ - [ Getting a bot] ( #getting-a-bot )
15+ - [ Getting several bots] ( #getting-several-bots )
16+ - [ Getting your project's voters] ( #getting-your-projects-voters )
17+ - [ Check if a user has voted for your project] ( #check-if-a-user-has-voted-for-your-project )
18+ - [ Getting your bot's statistics] ( #getting-your-bots-statistics )
19+ - [ Posting your bot's statistics] ( #posting-your-bots-statistics )
20+ - [ Automatically posting your bot's statistics every few minutes] ( #automatically-posting-your-bots-statistics-every-few-minutes )
21+ - [ Checking if the weekend vote multiplier is active] ( #checking-if-the-weekend-vote-multiplier-is-active )
22+ - [ Generating widget URLs] ( #generating-widget-urls )
23+ - [ Webhooks] ( #webhooks )
24+ - [ Being notified whenever someone voted for your project] ( #being-notified-whenever-someone-voted-for-your-project )
25+
526## Installation
627
728``` sh
@@ -10,74 +31,116 @@ $ composer require top-gg/php-sdk
1031
1132## Setting up
1233
34+ ### API v1
35+
36+ > ** NOTE** : API v1 also includes API v0.
37+
38+ ``` php
39+ include_once __DIR__ . "/vendor/autoload.php";
40+
41+ use DBL\V1DBL;
42+
43+ $client = new V1DBL([
44+ "token" => "Top.gg API token"
45+ ]);
46+ ```
47+
48+ ### API v0
49+
1350``` php
1451include_once __DIR__ . "/vendor/autoload.php";
1552
1653use DBL\DBL;
1754
1855$client = new DBL([
19- "token" => "Insert your Top.gg API token here. "
56+ "token" => "Top.gg API token"
2057]);
2158```
2259
2360## Usage
2461
25- ### Getting a bot
62+ ### API v1
63+
64+ #### Getting your project's vote information of a user
2665
2766``` php
28- $bot = $client->get_bot( );
67+ $vote = $client->get_vote(661200758510977084 );
2968```
3069
31- ### Getting several bots
70+ #### Posting your bot's application commands list
3271
33- #### With defaults
72+ ``` php
73+ $client->post_commands([
74+ [
75+ "options" => [],
76+ "name" => "test",
77+ "name_localizations" => null,
78+ "description" => "command description",
79+ "description_localizations" => null,
80+ "contexts" => [],
81+ "default_permission" => null,
82+ "default_member_permissions" => null,
83+ "dm_permission" => false,
84+ "integration_types" => [],
85+ "nsfw" => false
86+ ]
87+ ]);
88+ ```
89+
90+ ### API v0
91+
92+ #### Getting a bot
3493
3594``` php
36- $bots = $client->get_bots( );
95+ $bot = $client->get_bot(1026525568344264724 );
3796```
3897
39- #### With explicit arguments
98+ #### Getting several bots
4099
41100``` php
42101// Limit Offset Sort by
43- $bots = $client->get_bots(50, 0, "date ");
102+ $bots = $client->get_bots(50, 0, "monthlyPoints ");
44103```
45104
46- ### Getting your bot 's voters
105+ #### Getting your project 's voters
47106
48- #### First page
107+ ##### First page
49108
50109``` php
51- $voters = $client->get_voters ();
110+ $voters = $client->get_votes ();
52111```
53112
54- #### Subsequent pages
113+ ##### Subsequent pages
55114
56115``` php
57- $voters = $client->get_voters(2);
116+ // Bot ID (unused) Page number
117+ $voters = $client->get_votes(0, 2);
58118```
59119
60- ### Check if a user has voted for your bot
120+ #### Check if a user has voted for your project
61121
62122``` php
63- $has_voted = $client->has_voted(205680187394752512);
123+ // Bot ID (unused) User ID
124+ $has_voted = $client->get_user_vote(0, 661200758510977084);
64125```
65126
66- ### Getting your bot's server count
127+ #### Getting your bot's statistics
67128
68129``` php
69- $server_count = $client->get_server_count ();
130+ $stats = $client->get_stats ();
70131```
71132
72- ### Posting your bot's server count
133+ #### Posting your bot's statistics
73134
74135``` php
75- $client->post_server_count($bot->get_server_count());
136+ $client->post_stats(0, [
137+ "server_count" => $bot->get_server_count()
138+ ]);
76139```
77140
78- ### Automatically posting your bot's server count every few minutes
141+ #### Automatically posting your bot's statistics every few minutes
79142
80- > ** NOTE: ** Considering PHP's shortcomings, this is only possible via a URL.
143+ > ** NOTE** : Considering PHP's shortcomings, this is only possible via a URL.
81144
82145In your original client declaration:
83146
@@ -87,21 +150,23 @@ $client = new DBL([
87150 "auto_stats" => [
88151 "url": "Your URL",
89152 "callback": => function () use ($bot) {
90- return $bot->get_server_count();
153+ return [
154+ "server_count" => $bot->get_server_count()
155+ ];
91156 }
92157 ]
93158]);
94159```
95160
96- ### Checking if the weekend vote multiplier is active
161+ #### Checking if the weekend vote multiplier is active
97162
98163``` php
99164$is_weekend = $client->is_weekend();
100165```
101166
102- ### Generating widget URLs
167+ #### Generating widget URLs
103168
104- #### Large
169+ ##### Large
105170
106171``` php
107172use DBL\Widget;
@@ -110,7 +175,7 @@ use DBL\WidgetType;
110175$widget_url = Widget::large(WidgetType::DiscordBot, 574652751745777665);
111176```
112177
113- #### Votes
178+ ##### Votes
114179
115180``` php
116181use DBL\Widget;
@@ -119,7 +184,7 @@ use DBL\WidgetType;
119184$widget_url = Widget::votes(WidgetType::DiscordBot, 574652751745777665);
120185```
121186
122- #### Owner
187+ ##### Owner
123188
124189``` php
125190use DBL\Widget;
@@ -128,7 +193,7 @@ use DBL\WidgetType;
128193$widget_url = Widget::owner(WidgetType::DiscordBot, 574652751745777665);
129194```
130195
131- #### Social
196+ ##### Social
132197
133198``` php
134199use DBL\Widget;
@@ -139,7 +204,7 @@ $widget_url = Widget::social(WidgetType::DiscordBot, 574652751745777665);
139204
140205### Webhooks
141206
142- #### Being notified whenever someone voted for your bot
207+ #### Being notified whenever someone voted for your project
143208
144209** With Laravel:**
145210
0 commit comments