|
| 1 | +import { Service, ServicePostOptions } from '../Service' |
| 2 | +import { Util, IDResolvable } from '../../Utils/Util' |
| 3 | + |
| 4 | +/** |
| 5 | + * Represents the BotlistMe service. |
| 6 | + * @see https://docs.botlist.me |
| 7 | + */ |
| 8 | +export default class BotlistMe extends Service { |
| 9 | + /** The values that can be used to select the service. */ |
| 10 | + static get aliases() { |
| 11 | + return ['botlistme', 'botlist.me'] |
| 12 | + } |
| 13 | + |
| 14 | + /** The logo URL. */ |
| 15 | + static get logoURL() { |
| 16 | + return 'https://botlist.me/icon.png' |
| 17 | + } |
| 18 | + |
| 19 | + /** Service's name. */ |
| 20 | + static get serviceName() { |
| 21 | + return 'BotlistMe' |
| 22 | + } |
| 23 | + |
| 24 | + /** The website URL. */ |
| 25 | + static get websiteURL() { |
| 26 | + return 'https://botlist.me/' |
| 27 | + } |
| 28 | + |
| 29 | + /** The base URL of the service's API. */ |
| 30 | + static get baseURL() { |
| 31 | + return 'https://api.botlist.me/api/v1' |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * Posts statistics to this service. |
| 36 | + * <warn>Shard data posting is not supported for this service.</warn> |
| 37 | + * @param options The options of the request. |
| 38 | + */ |
| 39 | + static post(options: ServicePostOptions) { |
| 40 | + const { token, clientID, serverCount } = options |
| 41 | + return super._post({ |
| 42 | + method: 'post', |
| 43 | + url: `/bots/${Util.resolveID(clientID)}/stats/`, |
| 44 | + headers: { Authorization: token }, |
| 45 | + data: { server_count: Util.resolveCount(serverCount) } |
| 46 | + }) |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Gets whether a user has voted for a bot. |
| 51 | + * @param botID The bot's ID. |
| 52 | + * @param userID The user's ID. |
| 53 | + */ |
| 54 | + userVoted(botID: IDResolvable, userID: IDResolvable) { |
| 55 | + return this._request( |
| 56 | + { |
| 57 | + url: `/bots/${Util.resolveID(botID)}/voted`, |
| 58 | + headers: { Authorization: this.token }, |
| 59 | + params: { user_id: Util.resolveID(userID) } |
| 60 | + }, |
| 61 | + { requiresToken: true } |
| 62 | + ) |
| 63 | + } |
| 64 | +} |
0 commit comments