-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathBlist.ts
127 lines (113 loc) · 3.13 KB
/
Blist.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { Service, ServicePostOptions } from '../Service'
import { Util, IDResolvable } from '../../Utils/Util'
import { Query } from '../../Utils/Constants'
/**
* Represents the Blist service.
* @see https://blist.xyz/docs/
*/
export default class Blist extends Service {
/** The values that can be used to select the service. */
static get aliases() {
return ['blist', 'blist.xyz']
}
/** The logo URL. */
static get logoURL() {
return 'https://blist.xyz/main_site/staticfiles/main/assets/blist.png'
}
/** Service's name. */
static get serviceName() {
return 'Blist'
}
/** The website URL. */
static get websiteURL() {
return 'https://blist.xyz'
}
/** The base URL of the service's API. */
static get baseURL() {
return 'https://blist.xyz/api/v2'
}
/**
* Posts statistics to this service.
* @param options The options of the request
*/
static post(options: ServicePostOptions) {
const { token, clientID, serverCount, shard } = options
return super._post({
method: 'patch',
url: `/bot/${Util.resolveID(clientID)}/stats/`,
headers: { Authorization: token },
data: shard
? {
server_count: Util.resolveCount(serverCount),
shard_count: shard.count
}
: { server_count: Util.resolveCount(serverCount) }
})
}
/**
* Gets the user listed on this service.
* @param id The user's ID
*/
getUser(id: IDResolvable) {
return this._request({ url: `/user/${Util.resolveID(id)}` })
}
/**
* Gets the user's bots listed on this service.
* @param id The user's ID
*/
getUserBots(id: IDResolvable) {
return this._request({ url: `/user/${Util.resolveID(id)}/bots` })
}
/**
* Gets the user's servers listed on this service.
* @param id The user's ID
*/
getUserServers(id: IDResolvable) {
return this._request({ url: `/user/${Util.resolveID(id)}/servers` })
}
/**
* Gets the server listed on this service.
* @param id The server's ID
*/
getServer(id: IDResolvable) {
return this._request({ url: `/server/${Util.resolveID(id)}` })
}
/**
* Gets the bot listed on this service.
* @param id The bot's ID
*/
getBot(id: IDResolvable) {
return this._request({ url: `/bot/${Util.resolveID(id)}` })
}
/**
* Gets the list of people who voted this bot on this service.
* @param id The bot's ID
*/
getBotVotes(id: IDResolvable) {
return this._request(
{
url: `/bot/${Util.resolveID(id)}/votes`,
headers: { Authorization: this.token }
},
{
requiresToken: true
}
)
}
/**
* Gets the bot's reviews on this service.
* @param id The bot's ID
*/
getBotReviews(id: IDResolvable) {
return this._request({ url: `/bot/${Util.resolveID(id)}/reviews` })
}
/**
* Gets the widget URL for this bot.
* @param id The bot's ID
* @param query The query string that will be used in the request
*/
getWidgetURL(id: IDResolvable, query: Query) {
const actualQuery = Object.assign({ type: 'normal' }, query)
return this._appendQuery(`/bot/${Util.resolveID(id)}/widget`, actualQuery)
}
}