dbots
Version:
Discord bot list poster and stats retriever
123 lines (122 loc) • 4.34 kB
JavaScript
;
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 Radarcord service (formerly Radar Bot Directory).
* @see https://docs.radarcord.net/
*/
var Radarcord = /** @class */ (function (_super) {
__extends(Radarcord, _super);
function Radarcord() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(Radarcord, "aliases", {
/** The values that can be used to select the service. */
get: function () {
return [
'radar',
'radarbots',
'radarbotdirectory.xyz',
'radarcord',
'radarcord.net'
];
},
enumerable: false,
configurable: true
});
Object.defineProperty(Radarcord, "logoURL", {
/** The logo URL. */
get: function () {
return 'https://radarcord.net/static/logo.png';
},
enumerable: false,
configurable: true
});
Object.defineProperty(Radarcord, "serviceName", {
/** Service's name. */
get: function () {
return 'Radarcord';
},
enumerable: false,
configurable: true
});
Object.defineProperty(Radarcord, "websiteURL", {
/** The website URL. */
get: function () {
return 'https://radarcord.net/';
},
enumerable: false,
configurable: true
});
Object.defineProperty(Radarcord, "baseURL", {
/** The base URL of the service's API. */
get: function () {
return 'https://api.radarcord.net';
},
enumerable: false,
configurable: true
});
/**
* Posts statistics to this service.
* @param options The options of the request
*/
Radarcord.post = function (options) {
var token = options.token, clientID = options.clientID, serverCount = options.serverCount, shard = options.shard;
return _super._post.call(this, {
method: 'post',
url: "/bot/".concat(Util_1.Util.resolveID(clientID), "/stats/"),
headers: { Authorization: token },
data: shard
? {
guilds: Util_1.Util.resolveCount(serverCount),
shards: shard.count
}
: { guilds: Util_1.Util.resolveCount(serverCount) }
});
};
/**
* Gets the bot listed on this service.
* @param id The bot's ID
*/
Radarcord.prototype.getBot = function (id) {
return this._request({ url: "/bot/".concat(Util_1.Util.resolveID(id)) });
};
/**
* Gets the Unix Epoch Timestamp of the last time this user voted for this bot on this service.
* @param botID The bot's ID
* @param userID The user's ID
*/
Radarcord.prototype.getBotVotes = function (botID, userID) {
return this._request({
url: "/lastvoted/".concat(Util_1.Util.resolveID(userID), "/").concat(Util_1.Util.resolveID(botID)),
headers: { Authorization: this.token }
}, {
requiresToken: true
});
};
/**
* Gets the bot's reviews on this service.
* @param id The bot's ID
*/
Radarcord.prototype.getBotReviews = function (id) {
return this._request({ url: "/bot/".concat(Util_1.Util.resolveID(id), "/reviews") });
};
return Radarcord;
}(Service_1.Service));
exports.default = Radarcord;