Skip to content

Commit 0dc2a57

Browse files
committed
fix(TopGG): update API
I've added authorization to every method, since it seems to solve the 401 error reported in issue #174
1 parent 3e47c1a commit 0dc2a57

File tree

3 files changed

+71
-36
lines changed

3 files changed

+71
-36
lines changed

lib/Interface/Lists/TopGG.d.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class TopGG extends Service {
2727
*/
2828
getUser(id: IDResolvable): Promise<import("axios").AxiosResponse<any>>;
2929
/**
30-
* Gets the list of bots on this service.
30+
* Gets the a of bots on this service that match your query (refer to Top.gg docs for query parameters).
3131
* @param query The query string that will be used in the request
3232
*/
3333
getBots(query: Query): Promise<import("axios").AxiosResponse<any>>;
@@ -44,15 +44,14 @@ export default class TopGG extends Service {
4444
/**
4545
* Gets the list of people who voted this bot on this service.
4646
* @param id The bot's ID
47-
* @param query The query string that will be used in the request
4847
*/
49-
getBotVotes(id: IDResolvable, query?: Query): Promise<import("axios").AxiosResponse<any>>;
48+
getBotVotes(id: IDResolvable): Promise<import("axios").AxiosResponse<any>>;
5049
/**
5150
* Checks whether or not a user has voted for a bot on this service.
52-
* @param id The bot's ID
51+
* @param botId The bot's ID
5352
* @param userID The user's ID
5453
*/
55-
userVoted(id: IDResolvable, userID: IDResolvable): Promise<import("axios").AxiosResponse<any>>;
54+
userVoted(botId: IDResolvable, userID: IDResolvable): Promise<import("axios").AxiosResponse<any>>;
5655
/**
5756
* Gets the widget URL for this bot.
5857
* @param id The bot's ID

lib/Interface/Lists/TopGG.js

+23-14
Original file line numberDiff line numberDiff line change
@@ -88,50 +88,59 @@ var TopGG = /** @class */ (function (_super) {
8888
* @param id The user's ID
8989
*/
9090
TopGG.prototype.getUser = function (id) {
91-
return this._request({ url: "/users/" + Util_1.Util.resolveID(id) });
91+
return this._request({
92+
url: "/users/" + Util_1.Util.resolveID(id),
93+
headers: { Authorization: this.token }
94+
}, { requiresToken: true });
9295
};
9396
/**
94-
* Gets the list of bots on this service.
97+
* Gets the a of bots on this service that match your query (refer to Top.gg docs for query parameters).
9598
* @param query The query string that will be used in the request
9699
*/
97100
TopGG.prototype.getBots = function (query) {
98-
return this._request({ url: '/bots', params: query });
101+
return this._request({ url: '/bots', params: query, headers: { Authorization: this.token } }, { requiresToken: true });
99102
};
100103
/**
101104
* Gets the bot listed on this service.
102105
* @param id The bot's ID
103106
*/
104107
TopGG.prototype.getBot = function (id) {
105-
return this._request({ url: "/bots/" + Util_1.Util.resolveID(id) });
108+
return this._request({
109+
url: "/bots/" + Util_1.Util.resolveID(id),
110+
headers: { Authorization: this.token }
111+
}, { requiresToken: true });
106112
};
107113
/**
108114
* Gets the bot's stats listed on this service.
109115
* @param id The bot's ID
110116
*/
111117
TopGG.prototype.getBotStats = function (id) {
112-
return this._request({ url: "/bots/" + Util_1.Util.resolveID(id) + "/stats" });
118+
return this._request({
119+
url: "/bots/" + Util_1.Util.resolveID(id) + "/stats",
120+
headers: { Authorization: this.token }
121+
}, { requiresToken: true });
113122
};
114123
/**
115124
* Gets the list of people who voted this bot on this service.
116125
* @param id The bot's ID
117-
* @param query The query string that will be used in the request
118126
*/
119-
TopGG.prototype.getBotVotes = function (id, query) {
127+
TopGG.prototype.getBotVotes = function (id) {
120128
return this._request({
121129
url: "/bots/" + Util_1.Util.resolveID(id) + "/votes",
122-
params: query
123-
});
130+
headers: { Authorization: this.token }
131+
}, { requiresToken: true });
124132
};
125133
/**
126134
* Checks whether or not a user has voted for a bot on this service.
127-
* @param id The bot's ID
135+
* @param botId The bot's ID
128136
* @param userID The user's ID
129137
*/
130-
TopGG.prototype.userVoted = function (id, userID) {
138+
TopGG.prototype.userVoted = function (botId, userID) {
131139
return this._request({
132-
url: "/bots/" + Util_1.Util.resolveID(id) + "/check",
133-
params: { userId: Util_1.Util.resolveID(userID) }
134-
});
140+
url: "/bots/" + Util_1.Util.resolveID(botId) + "/check",
141+
params: { userId: Util_1.Util.resolveID(userID) },
142+
headers: { Authorization: this.token }
143+
}, { requiresToken: true });
135144
};
136145
/**
137146
* Gets the widget URL for this bot.

src/Interface/Lists/TopGG.ts

+44-17
Original file line numberDiff line numberDiff line change
@@ -57,55 +57,82 @@ export default class TopGG extends Service {
5757
* @param id The user's ID
5858
*/
5959
getUser(id: IDResolvable) {
60-
return this._request({ url: `/users/${Util.resolveID(id)}` })
60+
return this._request(
61+
{
62+
url: `/users/${Util.resolveID(id)}`,
63+
headers: { Authorization: this.token }
64+
},
65+
{ requiresToken: true }
66+
)
6167
}
6268

6369
/**
64-
* Gets the list of bots on this service.
70+
* Gets the a of bots on this service that match your query (refer to Top.gg docs for query parameters).
6571
* @param query The query string that will be used in the request
6672
*/
6773
getBots(query: Query) {
68-
return this._request({ url: '/bots', params: query })
74+
return this._request(
75+
{ url: '/bots', params: query, headers: { Authorization: this.token } },
76+
{ requiresToken: true }
77+
)
6978
}
7079

7180
/**
7281
* Gets the bot listed on this service.
7382
* @param id The bot's ID
7483
*/
7584
getBot(id: IDResolvable) {
76-
return this._request({ url: `/bots/${Util.resolveID(id)}` })
85+
return this._request(
86+
{
87+
url: `/bots/${Util.resolveID(id)}`,
88+
headers: { Authorization: this.token }
89+
},
90+
{ requiresToken: true }
91+
)
7792
}
7893

7994
/**
8095
* Gets the bot's stats listed on this service.
8196
* @param id The bot's ID
8297
*/
8398
getBotStats(id: IDResolvable) {
84-
return this._request({ url: `/bots/${Util.resolveID(id)}/stats` })
99+
return this._request(
100+
{
101+
url: `/bots/${Util.resolveID(id)}/stats`,
102+
headers: { Authorization: this.token }
103+
},
104+
{ requiresToken: true }
105+
)
85106
}
86107

87108
/**
88109
* Gets the list of people who voted this bot on this service.
89110
* @param id The bot's ID
90-
* @param query The query string that will be used in the request
91111
*/
92-
getBotVotes(id: IDResolvable, query?: Query) {
93-
return this._request({
94-
url: `/bots/${Util.resolveID(id)}/votes`,
95-
params: query
96-
})
112+
getBotVotes(id: IDResolvable) {
113+
return this._request(
114+
{
115+
url: `/bots/${Util.resolveID(id)}/votes`,
116+
headers: { Authorization: this.token }
117+
},
118+
{ requiresToken: true }
119+
)
97120
}
98121

99122
/**
100123
* Checks whether or not a user has voted for a bot on this service.
101-
* @param id The bot's ID
124+
* @param botId The bot's ID
102125
* @param userID The user's ID
103126
*/
104-
userVoted(id: IDResolvable, userID: IDResolvable) {
105-
return this._request({
106-
url: `/bots/${Util.resolveID(id)}/check`,
107-
params: { userId: Util.resolveID(userID) }
108-
})
127+
userVoted(botId: IDResolvable, userID: IDResolvable) {
128+
return this._request(
129+
{
130+
url: `/bots/${Util.resolveID(botId)}/check`,
131+
params: { userId: Util.resolveID(userID) },
132+
headers: { Authorization: this.token }
133+
},
134+
{ requiresToken: true }
135+
)
109136
}
110137

111138
/**

0 commit comments

Comments
 (0)