UNPKG

dbots

Version:

Discord bot list poster and stats retriever

140 lines (139 loc) 5.07 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var Service_1 = require("../Service"); var Util_1 = require("../../Utils/Util"); /** * Represents the Discords.com service (formerly Bots For Discord). * @see https://docs.discords.com/ */ var DiscordsCom = /** @class */ (function (_super) { __extends(DiscordsCom, _super); function DiscordsCom() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(DiscordsCom, "aliases", { /** The values that can be used to select the service. */ get: function () { return ['botsfordiscord', 'botsfordiscord.com', 'discords', 'discords.com']; }, enumerable: false, configurable: true }); Object.defineProperty(DiscordsCom, "logoURL", { /** The logo URL. */ get: function () { return 'https://discords.com/bots/img/manifest/icon-512x512.png'; }, enumerable: false, configurable: true }); Object.defineProperty(DiscordsCom, "serviceName", { /** Service's name. */ get: function () { return 'Discords.com'; }, enumerable: false, configurable: true }); Object.defineProperty(DiscordsCom, "websiteURL", { /** The website URL. */ get: function () { return 'https://discords.com/bots'; }, enumerable: false, configurable: true }); Object.defineProperty(DiscordsCom, "baseURL", { /** The base URL of the service's API. */ get: function () { return 'https://discords.com/bots/api'; }, enumerable: false, configurable: true }); /** * Posts statistics to this service. * <warn>Shard data posting is not supported for this service.</warn> * @param options The options of the request. */ DiscordsCom.post = function (options) { var token = options.token, clientID = options.clientID, serverCount = options.serverCount; return _super._post.call(this, { method: 'post', url: "/bot/".concat(Util_1.Util.resolveID(clientID), "/setservers"), headers: { Authorization: token }, data: { server_count: Util_1.Util.resolveCount(serverCount) } }); }; /** * Gets the bot listed on this service. * @param id The bot's ID. */ DiscordsCom.prototype.getBot = function (id) { return this._request({ url: "/bot/".concat(Util_1.Util.resolveID(id)) }); }; /** * Gets the list of people who voted a bot. * @param id The bot's ID. */ DiscordsCom.prototype.getBotVotes = function (id) { return this._request({ url: "/bot/".concat(Util_1.Util.resolveID(id), "/votes"), headers: { Authorization: this.token, 'Content-Type': 'application/json' } }, { requiresToken: true }); }; /** * Gets the list of people who voted a bot in the last 12 hours. * @param id The bot's ID. */ DiscordsCom.prototype.getBotVotes12h = function (id) { return this._request({ url: "/bot/".concat(Util_1.Util.resolveID(id), "/votes12h"), headers: { Authorization: this.token } }, { requiresToken: true }); }; /** * Gets the user listed on this service. * @param id The user's ID. */ DiscordsCom.prototype.getUser = function (id) { return this._request({ url: "/user/".concat(Util_1.Util.resolveID(id)) }); }; /** * Gets the user's bots listed for this service. * @param id The user's ID. */ DiscordsCom.prototype.getUserBots = function (id) { return this._request({ url: "/user/".concat(Util_1.Util.resolveID(id), "/bots") }); }; /** * Gets the widget URL for this bot. * @param id The bot's ID. * @param query The query that will be used in the request. */ DiscordsCom.prototype.getWidgetURL = function (id, query) { return this._appendQuery("/bot/".concat(Util_1.Util.resolveID(id), "/widget"), query || {}); }; return DiscordsCom; }(Service_1.Service)); exports.default = DiscordsCom;