Experimental active ratelimits (adapted from Eris)

This commit is contained in:
abalabahaha
2016-07-29 05:37:43 +09:00
parent dc939c48ee
commit 952cfc0456
7 changed files with 511 additions and 328 deletions

View File

@@ -15,6 +15,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _UtilBucket = require("../Util/Bucket");
var _UtilBucket2 = _interopRequireDefault(_UtilBucket);
var _UtilEquality = require("../Util/Equality");
var _UtilEquality2 = _interopRequireDefault(_UtilEquality);
@@ -55,13 +59,21 @@ var Server = (function (_Equality) {
_Equality.call(this);
var self = this;
this.client = client;
this.id = data.id;
if (data.owner_id) {
// new server data
client.internal.buckets["bot:msg:guild:" + this.id] = new _UtilBucket2["default"](5, 5000);
client.internal.buckets["dmsg:" + this.id] = new _UtilBucket2["default"](5, 1000);
client.internal.buckets["bdmsg:" + this.id] = new _UtilBucket2["default"](1, 1000);
client.internal.buckets["guild_member:" + this.id] = new _UtilBucket2["default"](10, 10000);
client.internal.buckets["guild_member_nick:" + this.id] = new _UtilBucket2["default"](1, 1000);
}
this.region = data.region;
this.ownerID = data.owner_id || data.ownerID;
this.name = data.name;
this.id = data.id;
this.members = new _UtilCache2["default"]();
this.channels = new _UtilCache2["default"]();
this.roles = new _UtilCache2["default"]();
@@ -72,8 +84,6 @@ var Server = (function (_Equality) {
this.memberCount = data.member_count || data.memberCount;
this.large = data.large || this.memberCount > 250;
var self = this;
if (data.roles instanceof _UtilCache2["default"]) {
data.roles.forEach(function (role) {
return _this.roles.add(role);