disney.js 0.0.1-security → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of disney.js might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +37 -3
- package/dist/client/bot.d.ts +10 -0
- package/dist/client/connection.d.ts +12 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/interface.d.ts +19 -0
- package/dist/client/message.client.d.ts +4 -0
- package/dist/disney.js.cjs.development.js +1872 -0
- package/dist/disney.js.cjs.development.js.map +1 -0
- package/dist/disney.js.cjs.production.min.js +2 -0
- package/dist/disney.js.cjs.production.min.js.map +1 -0
- package/dist/disney.js.esm.js +1859 -0
- package/dist/disney.js.esm.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/services/channel/channel.dto.d.ts +2 -0
- package/dist/services/channel/channel.service.d.ts +25 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/interface.d.ts +9 -0
- package/dist/services/message/action.service.d.ts +34 -0
- package/dist/services/message/button.service.d.ts +22 -0
- package/dist/services/message/message.builder.d.ts +11 -0
- package/dist/services/message/message.dto.d.ts +10 -0
- package/dist/services/message/message.service.d.ts +30 -0
- package/dist/services/message/select.service.d.ts +34 -0
- package/dist/services/worker.d.ts +12 -0
- package/dist/shared/config.d.ts +3 -0
- package/dist/shared/entities/action.entity.d.ts +11 -0
- package/dist/shared/entities/bot.entity.d.ts +16 -0
- package/dist/shared/entities/button.entity.d.ts +16 -0
- package/dist/shared/entities/channel.entity.d.ts +14 -0
- package/dist/shared/entities/channelCategory.entity.d.ts +8 -0
- package/dist/shared/entities/command.entity.d.ts +8 -0
- package/dist/shared/entities/emoji.entity.d.ts +9 -0
- package/dist/shared/entities/guild.entity.d.ts +13 -0
- package/dist/shared/entities/index.d.ts +14 -0
- package/dist/shared/entities/member.entity.d.ts +20 -0
- package/dist/shared/entities/message.entity.d.ts +13 -0
- package/dist/shared/entities/option.entity.d.ts +7 -0
- package/dist/shared/entities/react.entity.d.ts +9 -0
- package/dist/shared/entities/role.entity.d.ts +14 -0
- package/dist/shared/entities/select.entity.d.ts +14 -0
- package/dist/shared/entities/user.entity.d.ts +14 -0
- package/dist/shared/entities/userBeFriend.entity.d.ts +12 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/socket/emit.d.ts +59 -0
- package/dist/shared/socket/error.dto.d.ts +3 -0
- package/dist/shared/socket/event.d.ts +59 -0
- package/dist/shared/socket/namespace.d.ts +14 -0
- package/package.json +76 -3
@@ -0,0 +1,1872 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
6
|
+
|
7
|
+
var commonTags = require('common-tags');
|
8
|
+
var socket_ioClient = require('socket.io-client');
|
9
|
+
var axios = _interopDefault(require('axios'));
|
10
|
+
|
11
|
+
function _regeneratorRuntime() {
|
12
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
13
|
+
|
14
|
+
_regeneratorRuntime = function () {
|
15
|
+
return exports;
|
16
|
+
};
|
17
|
+
|
18
|
+
var exports = {},
|
19
|
+
Op = Object.prototype,
|
20
|
+
hasOwn = Op.hasOwnProperty,
|
21
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
22
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
23
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
24
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
25
|
+
|
26
|
+
function define(obj, key, value) {
|
27
|
+
return Object.defineProperty(obj, key, {
|
28
|
+
value: value,
|
29
|
+
enumerable: !0,
|
30
|
+
configurable: !0,
|
31
|
+
writable: !0
|
32
|
+
}), obj[key];
|
33
|
+
}
|
34
|
+
|
35
|
+
try {
|
36
|
+
define({}, "");
|
37
|
+
} catch (err) {
|
38
|
+
define = function (obj, key, value) {
|
39
|
+
return obj[key] = value;
|
40
|
+
};
|
41
|
+
}
|
42
|
+
|
43
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
44
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
45
|
+
generator = Object.create(protoGenerator.prototype),
|
46
|
+
context = new Context(tryLocsList || []);
|
47
|
+
return generator._invoke = function (innerFn, self, context) {
|
48
|
+
var state = "suspendedStart";
|
49
|
+
return function (method, arg) {
|
50
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
51
|
+
|
52
|
+
if ("completed" === state) {
|
53
|
+
if ("throw" === method) throw arg;
|
54
|
+
return doneResult();
|
55
|
+
}
|
56
|
+
|
57
|
+
for (context.method = method, context.arg = arg;;) {
|
58
|
+
var delegate = context.delegate;
|
59
|
+
|
60
|
+
if (delegate) {
|
61
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
62
|
+
|
63
|
+
if (delegateResult) {
|
64
|
+
if (delegateResult === ContinueSentinel) continue;
|
65
|
+
return delegateResult;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
70
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
71
|
+
context.dispatchException(context.arg);
|
72
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
73
|
+
state = "executing";
|
74
|
+
var record = tryCatch(innerFn, self, context);
|
75
|
+
|
76
|
+
if ("normal" === record.type) {
|
77
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
78
|
+
return {
|
79
|
+
value: record.arg,
|
80
|
+
done: context.done
|
81
|
+
};
|
82
|
+
}
|
83
|
+
|
84
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
85
|
+
}
|
86
|
+
};
|
87
|
+
}(innerFn, self, context), generator;
|
88
|
+
}
|
89
|
+
|
90
|
+
function tryCatch(fn, obj, arg) {
|
91
|
+
try {
|
92
|
+
return {
|
93
|
+
type: "normal",
|
94
|
+
arg: fn.call(obj, arg)
|
95
|
+
};
|
96
|
+
} catch (err) {
|
97
|
+
return {
|
98
|
+
type: "throw",
|
99
|
+
arg: err
|
100
|
+
};
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
exports.wrap = wrap;
|
105
|
+
var ContinueSentinel = {};
|
106
|
+
|
107
|
+
function Generator() {}
|
108
|
+
|
109
|
+
function GeneratorFunction() {}
|
110
|
+
|
111
|
+
function GeneratorFunctionPrototype() {}
|
112
|
+
|
113
|
+
var IteratorPrototype = {};
|
114
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
115
|
+
return this;
|
116
|
+
});
|
117
|
+
var getProto = Object.getPrototypeOf,
|
118
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
119
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
120
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
121
|
+
|
122
|
+
function defineIteratorMethods(prototype) {
|
123
|
+
["next", "throw", "return"].forEach(function (method) {
|
124
|
+
define(prototype, method, function (arg) {
|
125
|
+
return this._invoke(method, arg);
|
126
|
+
});
|
127
|
+
});
|
128
|
+
}
|
129
|
+
|
130
|
+
function AsyncIterator(generator, PromiseImpl) {
|
131
|
+
function invoke(method, arg, resolve, reject) {
|
132
|
+
var record = tryCatch(generator[method], generator, arg);
|
133
|
+
|
134
|
+
if ("throw" !== record.type) {
|
135
|
+
var result = record.arg,
|
136
|
+
value = result.value;
|
137
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
138
|
+
invoke("next", value, resolve, reject);
|
139
|
+
}, function (err) {
|
140
|
+
invoke("throw", err, resolve, reject);
|
141
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
142
|
+
result.value = unwrapped, resolve(result);
|
143
|
+
}, function (error) {
|
144
|
+
return invoke("throw", error, resolve, reject);
|
145
|
+
});
|
146
|
+
}
|
147
|
+
|
148
|
+
reject(record.arg);
|
149
|
+
}
|
150
|
+
|
151
|
+
var previousPromise;
|
152
|
+
|
153
|
+
this._invoke = function (method, arg) {
|
154
|
+
function callInvokeWithMethodAndArg() {
|
155
|
+
return new PromiseImpl(function (resolve, reject) {
|
156
|
+
invoke(method, arg, resolve, reject);
|
157
|
+
});
|
158
|
+
}
|
159
|
+
|
160
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
161
|
+
};
|
162
|
+
}
|
163
|
+
|
164
|
+
function maybeInvokeDelegate(delegate, context) {
|
165
|
+
var method = delegate.iterator[context.method];
|
166
|
+
|
167
|
+
if (undefined === method) {
|
168
|
+
if (context.delegate = null, "throw" === context.method) {
|
169
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
170
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
171
|
+
}
|
172
|
+
|
173
|
+
return ContinueSentinel;
|
174
|
+
}
|
175
|
+
|
176
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
177
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
178
|
+
var info = record.arg;
|
179
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
180
|
+
}
|
181
|
+
|
182
|
+
function pushTryEntry(locs) {
|
183
|
+
var entry = {
|
184
|
+
tryLoc: locs[0]
|
185
|
+
};
|
186
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
187
|
+
}
|
188
|
+
|
189
|
+
function resetTryEntry(entry) {
|
190
|
+
var record = entry.completion || {};
|
191
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
192
|
+
}
|
193
|
+
|
194
|
+
function Context(tryLocsList) {
|
195
|
+
this.tryEntries = [{
|
196
|
+
tryLoc: "root"
|
197
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
198
|
+
}
|
199
|
+
|
200
|
+
function values(iterable) {
|
201
|
+
if (iterable) {
|
202
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
203
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
204
|
+
if ("function" == typeof iterable.next) return iterable;
|
205
|
+
|
206
|
+
if (!isNaN(iterable.length)) {
|
207
|
+
var i = -1,
|
208
|
+
next = function next() {
|
209
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
210
|
+
|
211
|
+
return next.value = undefined, next.done = !0, next;
|
212
|
+
};
|
213
|
+
|
214
|
+
return next.next = next;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
return {
|
219
|
+
next: doneResult
|
220
|
+
};
|
221
|
+
}
|
222
|
+
|
223
|
+
function doneResult() {
|
224
|
+
return {
|
225
|
+
value: undefined,
|
226
|
+
done: !0
|
227
|
+
};
|
228
|
+
}
|
229
|
+
|
230
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
231
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
232
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
233
|
+
}, exports.mark = function (genFun) {
|
234
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
235
|
+
}, exports.awrap = function (arg) {
|
236
|
+
return {
|
237
|
+
__await: arg
|
238
|
+
};
|
239
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
240
|
+
return this;
|
241
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
242
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
243
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
244
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
245
|
+
return result.done ? result.value : iter.next();
|
246
|
+
});
|
247
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
248
|
+
return this;
|
249
|
+
}), define(Gp, "toString", function () {
|
250
|
+
return "[object Generator]";
|
251
|
+
}), exports.keys = function (object) {
|
252
|
+
var keys = [];
|
253
|
+
|
254
|
+
for (var key in object) keys.push(key);
|
255
|
+
|
256
|
+
return keys.reverse(), function next() {
|
257
|
+
for (; keys.length;) {
|
258
|
+
var key = keys.pop();
|
259
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
260
|
+
}
|
261
|
+
|
262
|
+
return next.done = !0, next;
|
263
|
+
};
|
264
|
+
}, exports.values = values, Context.prototype = {
|
265
|
+
constructor: Context,
|
266
|
+
reset: function (skipTempReset) {
|
267
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
268
|
+
},
|
269
|
+
stop: function () {
|
270
|
+
this.done = !0;
|
271
|
+
var rootRecord = this.tryEntries[0].completion;
|
272
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
273
|
+
return this.rval;
|
274
|
+
},
|
275
|
+
dispatchException: function (exception) {
|
276
|
+
if (this.done) throw exception;
|
277
|
+
var context = this;
|
278
|
+
|
279
|
+
function handle(loc, caught) {
|
280
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
281
|
+
}
|
282
|
+
|
283
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
284
|
+
var entry = this.tryEntries[i],
|
285
|
+
record = entry.completion;
|
286
|
+
if ("root" === entry.tryLoc) return handle("end");
|
287
|
+
|
288
|
+
if (entry.tryLoc <= this.prev) {
|
289
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
290
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
291
|
+
|
292
|
+
if (hasCatch && hasFinally) {
|
293
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
294
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
295
|
+
} else if (hasCatch) {
|
296
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
297
|
+
} else {
|
298
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
299
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
300
|
+
}
|
301
|
+
}
|
302
|
+
}
|
303
|
+
},
|
304
|
+
abrupt: function (type, arg) {
|
305
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
306
|
+
var entry = this.tryEntries[i];
|
307
|
+
|
308
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
309
|
+
var finallyEntry = entry;
|
310
|
+
break;
|
311
|
+
}
|
312
|
+
}
|
313
|
+
|
314
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
315
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
316
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
317
|
+
},
|
318
|
+
complete: function (record, afterLoc) {
|
319
|
+
if ("throw" === record.type) throw record.arg;
|
320
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
321
|
+
},
|
322
|
+
finish: function (finallyLoc) {
|
323
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
324
|
+
var entry = this.tryEntries[i];
|
325
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
326
|
+
}
|
327
|
+
},
|
328
|
+
catch: function (tryLoc) {
|
329
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
330
|
+
var entry = this.tryEntries[i];
|
331
|
+
|
332
|
+
if (entry.tryLoc === tryLoc) {
|
333
|
+
var record = entry.completion;
|
334
|
+
|
335
|
+
if ("throw" === record.type) {
|
336
|
+
var thrown = record.arg;
|
337
|
+
resetTryEntry(entry);
|
338
|
+
}
|
339
|
+
|
340
|
+
return thrown;
|
341
|
+
}
|
342
|
+
}
|
343
|
+
|
344
|
+
throw new Error("illegal catch attempt");
|
345
|
+
},
|
346
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
347
|
+
return this.delegate = {
|
348
|
+
iterator: values(iterable),
|
349
|
+
resultName: resultName,
|
350
|
+
nextLoc: nextLoc
|
351
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
352
|
+
}
|
353
|
+
}, exports;
|
354
|
+
}
|
355
|
+
|
356
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
357
|
+
try {
|
358
|
+
var info = gen[key](arg);
|
359
|
+
var value = info.value;
|
360
|
+
} catch (error) {
|
361
|
+
reject(error);
|
362
|
+
return;
|
363
|
+
}
|
364
|
+
|
365
|
+
if (info.done) {
|
366
|
+
resolve(value);
|
367
|
+
} else {
|
368
|
+
Promise.resolve(value).then(_next, _throw);
|
369
|
+
}
|
370
|
+
}
|
371
|
+
|
372
|
+
function _asyncToGenerator(fn) {
|
373
|
+
return function () {
|
374
|
+
var self = this,
|
375
|
+
args = arguments;
|
376
|
+
return new Promise(function (resolve, reject) {
|
377
|
+
var gen = fn.apply(self, args);
|
378
|
+
|
379
|
+
function _next(value) {
|
380
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
381
|
+
}
|
382
|
+
|
383
|
+
function _throw(err) {
|
384
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
385
|
+
}
|
386
|
+
|
387
|
+
_next(undefined);
|
388
|
+
});
|
389
|
+
};
|
390
|
+
}
|
391
|
+
|
392
|
+
function _defineProperties(target, props) {
|
393
|
+
for (var i = 0; i < props.length; i++) {
|
394
|
+
var descriptor = props[i];
|
395
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
396
|
+
descriptor.configurable = true;
|
397
|
+
if ("value" in descriptor) descriptor.writable = true;
|
398
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
399
|
+
}
|
400
|
+
}
|
401
|
+
|
402
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
403
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
404
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
405
|
+
Object.defineProperty(Constructor, "prototype", {
|
406
|
+
writable: false
|
407
|
+
});
|
408
|
+
return Constructor;
|
409
|
+
}
|
410
|
+
|
411
|
+
function _extends() {
|
412
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
413
|
+
for (var i = 1; i < arguments.length; i++) {
|
414
|
+
var source = arguments[i];
|
415
|
+
|
416
|
+
for (var key in source) {
|
417
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
418
|
+
target[key] = source[key];
|
419
|
+
}
|
420
|
+
}
|
421
|
+
}
|
422
|
+
|
423
|
+
return target;
|
424
|
+
};
|
425
|
+
return _extends.apply(this, arguments);
|
426
|
+
}
|
427
|
+
|
428
|
+
function _inheritsLoose(subClass, superClass) {
|
429
|
+
subClass.prototype = Object.create(superClass.prototype);
|
430
|
+
subClass.prototype.constructor = subClass;
|
431
|
+
|
432
|
+
_setPrototypeOf(subClass, superClass);
|
433
|
+
}
|
434
|
+
|
435
|
+
function _setPrototypeOf(o, p) {
|
436
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
437
|
+
o.__proto__ = p;
|
438
|
+
return o;
|
439
|
+
};
|
440
|
+
return _setPrototypeOf(o, p);
|
441
|
+
}
|
442
|
+
|
443
|
+
function _unsupportedIterableToArray(o, minLen) {
|
444
|
+
if (!o) return;
|
445
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
446
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
447
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
448
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
449
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
450
|
+
}
|
451
|
+
|
452
|
+
function _arrayLikeToArray(arr, len) {
|
453
|
+
if (len == null || len > arr.length) len = arr.length;
|
454
|
+
|
455
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
456
|
+
|
457
|
+
return arr2;
|
458
|
+
}
|
459
|
+
|
460
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
461
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
462
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
463
|
+
|
464
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
465
|
+
if (it) o = it;
|
466
|
+
var i = 0;
|
467
|
+
return function () {
|
468
|
+
if (i >= o.length) return {
|
469
|
+
done: true
|
470
|
+
};
|
471
|
+
return {
|
472
|
+
done: false,
|
473
|
+
value: o[i++]
|
474
|
+
};
|
475
|
+
};
|
476
|
+
}
|
477
|
+
|
478
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
479
|
+
}
|
480
|
+
|
481
|
+
var Service = /*#__PURE__*/function () {
|
482
|
+
function Service() {}
|
483
|
+
|
484
|
+
var _proto = Service.prototype;
|
485
|
+
|
486
|
+
_proto.setWorker = function setWorker(worker) {
|
487
|
+
this._worker = worker;
|
488
|
+
return this;
|
489
|
+
};
|
490
|
+
|
491
|
+
_createClass(Service, [{
|
492
|
+
key: "worker",
|
493
|
+
get: function get() {
|
494
|
+
if (!this._worker) throw new Error('Worker is not initialized');
|
495
|
+
return this._worker;
|
496
|
+
}
|
497
|
+
}, {
|
498
|
+
key: "guild",
|
499
|
+
get: function get() {
|
500
|
+
if (!this._worker) throw new Error('Worker is not initialized');
|
501
|
+
return this.worker.guild;
|
502
|
+
}
|
503
|
+
}]);
|
504
|
+
|
505
|
+
return Service;
|
506
|
+
}();
|
507
|
+
|
508
|
+
var Worker = /*#__PURE__*/function () {
|
509
|
+
function Worker(_connection, _botMember, _guild) {
|
510
|
+
this._connection = _connection;
|
511
|
+
this._botMember = _botMember;
|
512
|
+
this._guild = _guild;
|
513
|
+
}
|
514
|
+
|
515
|
+
_createClass(Worker, [{
|
516
|
+
key: "connection",
|
517
|
+
get: function get() {
|
518
|
+
return this._connection;
|
519
|
+
}
|
520
|
+
}, {
|
521
|
+
key: "botMember",
|
522
|
+
get: function get() {
|
523
|
+
return this._botMember;
|
524
|
+
}
|
525
|
+
}, {
|
526
|
+
key: "guild",
|
527
|
+
get: function get() {
|
528
|
+
return this._guild;
|
529
|
+
}
|
530
|
+
}]);
|
531
|
+
|
532
|
+
return Worker;
|
533
|
+
}();
|
534
|
+
|
535
|
+
var UserSocketEvent;
|
536
|
+
|
537
|
+
(function (UserSocketEvent) {
|
538
|
+
UserSocketEvent["ONLINE"] = "online";
|
539
|
+
UserSocketEvent["UPDATE_PROFILE"] = "updateProfile";
|
540
|
+
UserSocketEvent["ADD_FRIEND"] = "addFriend";
|
541
|
+
UserSocketEvent["ACCEPT_FRIEND"] = "acceptFriend";
|
542
|
+
UserSocketEvent["BLOCK_FRIEND"] = "blockFriend";
|
543
|
+
})(UserSocketEvent || (UserSocketEvent = {}));
|
544
|
+
|
545
|
+
var GuildSocketEvent;
|
546
|
+
|
547
|
+
(function (GuildSocketEvent) {
|
548
|
+
GuildSocketEvent["CREATE"] = "create";
|
549
|
+
GuildSocketEvent["UPDATE"] = "update";
|
550
|
+
GuildSocketEvent["GET_ONE"] = "getOne";
|
551
|
+
GuildSocketEvent["GET_JOINED"] = "getJoined";
|
552
|
+
GuildSocketEvent["DELETE"] = "delete";
|
553
|
+
})(GuildSocketEvent || (GuildSocketEvent = {}));
|
554
|
+
|
555
|
+
var MemberSocketEvent;
|
556
|
+
|
557
|
+
(function (MemberSocketEvent) {
|
558
|
+
MemberSocketEvent["GET_JOINED"] = "getJoined";
|
559
|
+
MemberSocketEvent["ONLINE"] = "online";
|
560
|
+
MemberSocketEvent["UPDATE"] = "update";
|
561
|
+
MemberSocketEvent["USER_JOIN"] = "userJoin";
|
562
|
+
MemberSocketEvent["BOT_JOIN"] = "botJoin";
|
563
|
+
MemberSocketEvent["LEAVE"] = "leave";
|
564
|
+
})(MemberSocketEvent || (MemberSocketEvent = {}));
|
565
|
+
|
566
|
+
var ChannelCtgSocketEvent;
|
567
|
+
|
568
|
+
(function (ChannelCtgSocketEvent) {
|
569
|
+
ChannelCtgSocketEvent["CREATE"] = "create";
|
570
|
+
ChannelCtgSocketEvent["UPDATE"] = "update";
|
571
|
+
ChannelCtgSocketEvent["DELETE"] = "delete";
|
572
|
+
})(ChannelCtgSocketEvent || (ChannelCtgSocketEvent = {}));
|
573
|
+
|
574
|
+
var ChannelSocketEvent;
|
575
|
+
|
576
|
+
(function (ChannelSocketEvent) {
|
577
|
+
ChannelSocketEvent["CREATE"] = "create";
|
578
|
+
ChannelSocketEvent["UPDATE"] = "update";
|
579
|
+
ChannelSocketEvent["DELETE"] = "delete";
|
580
|
+
ChannelSocketEvent["ADD_MEMBER"] = "addMember";
|
581
|
+
ChannelSocketEvent["REMOVE_MEMBER"] = "removeMember";
|
582
|
+
})(ChannelSocketEvent || (ChannelSocketEvent = {}));
|
583
|
+
|
584
|
+
var RoleSocketEvent;
|
585
|
+
|
586
|
+
(function (RoleSocketEvent) {
|
587
|
+
RoleSocketEvent["CREATE"] = "create";
|
588
|
+
RoleSocketEvent["UPDATE"] = "update";
|
589
|
+
RoleSocketEvent["DELETE"] = "delete";
|
590
|
+
RoleSocketEvent["ADD_TO_MEMBER"] = "addToMember";
|
591
|
+
RoleSocketEvent["REMOVE_FROM_MEMBER"] = "removeFromMember";
|
592
|
+
RoleSocketEvent["ADD_TO_CHANNEL"] = "addToChannel";
|
593
|
+
RoleSocketEvent["REMOVE_FROM_CHANNEL"] = "removeFromChannel";
|
594
|
+
})(RoleSocketEvent || (RoleSocketEvent = {}));
|
595
|
+
|
596
|
+
var MessageSocketEvent;
|
597
|
+
|
598
|
+
(function (MessageSocketEvent) {
|
599
|
+
MessageSocketEvent["FIND"] = "find";
|
600
|
+
MessageSocketEvent["CREATE"] = "create";
|
601
|
+
MessageSocketEvent["UPDATE"] = "update";
|
602
|
+
MessageSocketEvent["DELETE"] = "delete";
|
603
|
+
})(MessageSocketEvent || (MessageSocketEvent = {}));
|
604
|
+
|
605
|
+
var EmojiSocketEvent;
|
606
|
+
|
607
|
+
(function (EmojiSocketEvent) {
|
608
|
+
EmojiSocketEvent["CREATE"] = "create";
|
609
|
+
EmojiSocketEvent["UPDATE"] = "update";
|
610
|
+
EmojiSocketEvent["DELETE"] = "delete";
|
611
|
+
})(EmojiSocketEvent || (EmojiSocketEvent = {}));
|
612
|
+
|
613
|
+
var ReactSocketEvent;
|
614
|
+
|
615
|
+
(function (ReactSocketEvent) {
|
616
|
+
ReactSocketEvent["CREATE"] = "create";
|
617
|
+
ReactSocketEvent["UPDATE"] = "update";
|
618
|
+
ReactSocketEvent["DELETE"] = "delete";
|
619
|
+
})(ReactSocketEvent || (ReactSocketEvent = {}));
|
620
|
+
|
621
|
+
var SocketNamespace;
|
622
|
+
|
623
|
+
(function (SocketNamespace) {
|
624
|
+
SocketNamespace["USER"] = "user";
|
625
|
+
SocketNamespace["GUILD"] = "guild";
|
626
|
+
SocketNamespace["CHANNEL"] = "channel";
|
627
|
+
SocketNamespace["CHANNEL_CATEGORY"] = "channel-category";
|
628
|
+
SocketNamespace["MEMBER"] = "member";
|
629
|
+
SocketNamespace["ROLE"] = "role";
|
630
|
+
SocketNamespace["EMOJI"] = "emoji";
|
631
|
+
SocketNamespace["REACT"] = "react";
|
632
|
+
SocketNamespace["MESSAGE"] = "message";
|
633
|
+
SocketNamespace["BUTTON"] = "button";
|
634
|
+
SocketNamespace["ACTION"] = "action";
|
635
|
+
SocketNamespace["SELECT"] = "select";
|
636
|
+
})(SocketNamespace || (SocketNamespace = {}));
|
637
|
+
|
638
|
+
var UserSocketEmit;
|
639
|
+
|
640
|
+
(function (UserSocketEmit) {
|
641
|
+
UserSocketEmit["ONLINE"] = "online";
|
642
|
+
UserSocketEmit["UPDATE_PROFILE"] = "updateProfile";
|
643
|
+
UserSocketEmit["ADD_FRIEND"] = "addFriend";
|
644
|
+
UserSocketEmit["ACCEPT_FRIEND"] = "acceptFriend";
|
645
|
+
UserSocketEmit["BLOCK_FRIEND"] = "blockFriend";
|
646
|
+
})(UserSocketEmit || (UserSocketEmit = {}));
|
647
|
+
|
648
|
+
var GuildSocketEmit;
|
649
|
+
|
650
|
+
(function (GuildSocketEmit) {
|
651
|
+
GuildSocketEmit["UPDATE"] = "update";
|
652
|
+
GuildSocketEmit["DELETE"] = "delete";
|
653
|
+
})(GuildSocketEmit || (GuildSocketEmit = {}));
|
654
|
+
|
655
|
+
var MemberSocketEmit;
|
656
|
+
|
657
|
+
(function (MemberSocketEmit) {
|
658
|
+
MemberSocketEmit["JOIN"] = "join";
|
659
|
+
MemberSocketEmit["LEAVE"] = "leave";
|
660
|
+
MemberSocketEmit["UPDATE"] = "ipdate";
|
661
|
+
MemberSocketEmit["ONLINE"] = "online";
|
662
|
+
})(MemberSocketEmit || (MemberSocketEmit = {}));
|
663
|
+
|
664
|
+
var ChannelCtgSocketEmit;
|
665
|
+
|
666
|
+
(function (ChannelCtgSocketEmit) {
|
667
|
+
ChannelCtgSocketEmit["CREATE"] = "create";
|
668
|
+
ChannelCtgSocketEmit["UPDATE"] = "update";
|
669
|
+
ChannelCtgSocketEmit["DELETE"] = "delete";
|
670
|
+
})(ChannelCtgSocketEmit || (ChannelCtgSocketEmit = {}));
|
671
|
+
|
672
|
+
var ChannelSocketEmit;
|
673
|
+
|
674
|
+
(function (ChannelSocketEmit) {
|
675
|
+
ChannelSocketEmit["CREATE"] = "create";
|
676
|
+
ChannelSocketEmit["UPDATE"] = "update";
|
677
|
+
ChannelSocketEmit["DELETE"] = "delete";
|
678
|
+
ChannelSocketEmit["ADD_MEMBER"] = "addMember";
|
679
|
+
ChannelSocketEmit["REMOVE_MEMBER"] = "removeMember";
|
680
|
+
})(ChannelSocketEmit || (ChannelSocketEmit = {}));
|
681
|
+
|
682
|
+
var RoleSocketEmit;
|
683
|
+
|
684
|
+
(function (RoleSocketEmit) {
|
685
|
+
RoleSocketEmit["CREATE"] = "create";
|
686
|
+
RoleSocketEmit["UPDATE"] = "update";
|
687
|
+
RoleSocketEmit["DELETE"] = "delete";
|
688
|
+
RoleSocketEmit["ADD_TO_MEMBER"] = "addToMember";
|
689
|
+
RoleSocketEmit["REMOVE_FROM_MEMBER"] = "removeFromMember";
|
690
|
+
RoleSocketEmit["ADD_TO_CHANNEL"] = "addToChannel";
|
691
|
+
RoleSocketEmit["REMOVE_FROM_CHANNEL"] = "removeFromChannel";
|
692
|
+
})(RoleSocketEmit || (RoleSocketEmit = {}));
|
693
|
+
|
694
|
+
var MessageSocketEmit;
|
695
|
+
|
696
|
+
(function (MessageSocketEmit) {
|
697
|
+
MessageSocketEmit["CREATE"] = "create";
|
698
|
+
MessageSocketEmit["UPDATE"] = "update";
|
699
|
+
MessageSocketEmit["DELETE"] = "delete";
|
700
|
+
})(MessageSocketEmit || (MessageSocketEmit = {}));
|
701
|
+
|
702
|
+
var EmojiSocketEmit;
|
703
|
+
|
704
|
+
(function (EmojiSocketEmit) {
|
705
|
+
EmojiSocketEmit["CREATE"] = "create";
|
706
|
+
EmojiSocketEmit["UPDATE"] = "update";
|
707
|
+
EmojiSocketEmit["DELETE"] = "delete";
|
708
|
+
})(EmojiSocketEmit || (EmojiSocketEmit = {}));
|
709
|
+
|
710
|
+
var ReactSocketEmit;
|
711
|
+
|
712
|
+
(function (ReactSocketEmit) {
|
713
|
+
ReactSocketEmit["CREATE"] = "create";
|
714
|
+
ReactSocketEmit["UPDATE"] = "update";
|
715
|
+
ReactSocketEmit["DELETE"] = "delete";
|
716
|
+
})(ReactSocketEmit || (ReactSocketEmit = {}));
|
717
|
+
|
718
|
+
var ButtonSocketEmit;
|
719
|
+
|
720
|
+
(function (ButtonSocketEmit) {
|
721
|
+
ButtonSocketEmit["CLICK"] = "click";
|
722
|
+
})(ButtonSocketEmit || (ButtonSocketEmit = {}));
|
723
|
+
|
724
|
+
var SelectSocketEmit;
|
725
|
+
|
726
|
+
(function (SelectSocketEmit) {
|
727
|
+
SelectSocketEmit["SELECT"] = "select";
|
728
|
+
})(SelectSocketEmit || (SelectSocketEmit = {}));
|
729
|
+
|
730
|
+
var MessageAction = /*#__PURE__*/function () {
|
731
|
+
function MessageAction() {
|
732
|
+
this.buttons = [];
|
733
|
+
this.reacts = [];
|
734
|
+
this.selects = [];
|
735
|
+
}
|
736
|
+
|
737
|
+
var _proto = MessageAction.prototype;
|
738
|
+
|
739
|
+
_proto.clearButton = function clearButton() {
|
740
|
+
this.buttons = [];
|
741
|
+
return this;
|
742
|
+
};
|
743
|
+
|
744
|
+
_proto.clearReact = function clearReact() {
|
745
|
+
this.reacts = [];
|
746
|
+
return this;
|
747
|
+
};
|
748
|
+
|
749
|
+
_proto.clearSelect = function clearSelect() {
|
750
|
+
this.selects = [];
|
751
|
+
return this;
|
752
|
+
};
|
753
|
+
|
754
|
+
_proto.clearAction = function clearAction() {
|
755
|
+
this.clearButton();
|
756
|
+
this.clearReact();
|
757
|
+
this.clearSelect();
|
758
|
+
return this;
|
759
|
+
};
|
760
|
+
|
761
|
+
_proto.addButton = function addButton(button) {
|
762
|
+
this.buttons.push(button.getData());
|
763
|
+
return this;
|
764
|
+
};
|
765
|
+
|
766
|
+
_proto.addButtons = function addButtons(buttons) {
|
767
|
+
this.buttons = this.buttons.concat(buttons.map(function (button) {
|
768
|
+
return button.getData();
|
769
|
+
}));
|
770
|
+
return this;
|
771
|
+
};
|
772
|
+
|
773
|
+
_proto.addReact = function addReact(emoji) {
|
774
|
+
this.reacts.push({
|
775
|
+
emoji: emoji
|
776
|
+
});
|
777
|
+
return this;
|
778
|
+
};
|
779
|
+
|
780
|
+
_proto.addReacts = function addReacts(emojis) {
|
781
|
+
this.reacts = this.reacts.concat(emojis.map(function (emoji) {
|
782
|
+
return {
|
783
|
+
emoji: emoji
|
784
|
+
};
|
785
|
+
}));
|
786
|
+
return this;
|
787
|
+
};
|
788
|
+
|
789
|
+
_proto.addSelect = function addSelect(select) {
|
790
|
+
this.selects.push(select.getData());
|
791
|
+
return this;
|
792
|
+
};
|
793
|
+
|
794
|
+
_proto.getData = function getData() {
|
795
|
+
return {
|
796
|
+
buttons: this.buttons,
|
797
|
+
reacts: this.reacts,
|
798
|
+
selects: this.selects
|
799
|
+
};
|
800
|
+
};
|
801
|
+
|
802
|
+
_proto.setId = function setId(id) {
|
803
|
+
this._actionId = id;
|
804
|
+
return this;
|
805
|
+
};
|
806
|
+
|
807
|
+
_proto.setConnection = function setConnection(connection) {
|
808
|
+
this._connection = connection;
|
809
|
+
return this;
|
810
|
+
};
|
811
|
+
|
812
|
+
_proto.onButtonClick = function onButtonClick(callback) {
|
813
|
+
this.checkId();
|
814
|
+
|
815
|
+
this._connection.button.on(this._actionId + "/" + SocketNamespace.BUTTON + "/" + ButtonSocketEmit.CLICK, function (interaction) {
|
816
|
+
callback(interaction);
|
817
|
+
});
|
818
|
+
};
|
819
|
+
|
820
|
+
_proto.onReactCreate = function onReactCreate(callback) {
|
821
|
+
this.checkId();
|
822
|
+
|
823
|
+
this._connection.react.on(this._actionId + "/" + SocketNamespace.REACT + "/" + ReactSocketEmit.CREATE, function (react) {
|
824
|
+
callback(react);
|
825
|
+
});
|
826
|
+
};
|
827
|
+
|
828
|
+
_proto.onReactDelete = function onReactDelete(callback) {
|
829
|
+
this.checkId();
|
830
|
+
|
831
|
+
this._connection.react.on(this._actionId + "/" + SocketNamespace.REACT + "/" + ReactSocketEmit.DELETE, function (react) {
|
832
|
+
callback(react);
|
833
|
+
});
|
834
|
+
};
|
835
|
+
|
836
|
+
_proto.onSelect = function onSelect(callback) {
|
837
|
+
this.checkId();
|
838
|
+
|
839
|
+
this._connection.select.on(this._actionId + "/" + SocketNamespace.SELECT + "/" + SelectSocketEmit.SELECT, function (interaction) {
|
840
|
+
callback(interaction);
|
841
|
+
});
|
842
|
+
};
|
843
|
+
|
844
|
+
_proto.checkId = function checkId() {
|
845
|
+
if (!this._actionId) throw new Error('Listener must be start in advance the message sent');
|
846
|
+
};
|
847
|
+
|
848
|
+
return MessageAction;
|
849
|
+
}();
|
850
|
+
|
851
|
+
var MessageService = /*#__PURE__*/function (_Service) {
|
852
|
+
_inheritsLoose(MessageService, _Service);
|
853
|
+
|
854
|
+
function MessageService(_client, _connection, initMessage) {
|
855
|
+
var _this;
|
856
|
+
|
857
|
+
_this = _Service.call(this) || this;
|
858
|
+
_this._client = _client;
|
859
|
+
_this._connection = _connection;
|
860
|
+
_this._route = _client.bot.info.botId + "/" + SocketNamespace.MESSAGE;
|
861
|
+
|
862
|
+
if (initMessage) {
|
863
|
+
_this._message = initMessage;
|
864
|
+
}
|
865
|
+
|
866
|
+
_this._action = new MessageAction();
|
867
|
+
return _this;
|
868
|
+
}
|
869
|
+
|
870
|
+
var _proto = MessageService.prototype;
|
871
|
+
|
872
|
+
_proto.onCreate = function onCreate(callback) {
|
873
|
+
var _this2 = this;
|
874
|
+
|
875
|
+
this._connection.message.on(this._route + "/create", function (message, inspectedCommand, guild) {
|
876
|
+
var member = _this2._client.bot.info.joinedGuilds.find(function (g) {
|
877
|
+
return g.guild.guildId === guild.guildId;
|
878
|
+
});
|
879
|
+
|
880
|
+
if (!member) {
|
881
|
+
throw new Error('Bot is not in this guild');
|
882
|
+
}
|
883
|
+
|
884
|
+
_this2._inspectedCommand = inspectedCommand;
|
885
|
+
_this2._message = message;
|
886
|
+
var worker = new Worker(_this2._connection.message, member, guild);
|
887
|
+
|
888
|
+
_this2.setWorker(worker);
|
889
|
+
|
890
|
+
callback({
|
891
|
+
worker: worker
|
892
|
+
});
|
893
|
+
});
|
894
|
+
};
|
895
|
+
|
896
|
+
_proto.onUpdate = function onUpdate(callback) {
|
897
|
+
this._connection.message.on(this._route + "/update", callback);
|
898
|
+
};
|
899
|
+
|
900
|
+
_proto.onDelete = function onDelete(callback) {
|
901
|
+
this._connection.message.on(this._route + "/delete", callback);
|
902
|
+
};
|
903
|
+
|
904
|
+
_proto.send = /*#__PURE__*/function () {
|
905
|
+
var _send = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(message) {
|
906
|
+
var _this3 = this;
|
907
|
+
|
908
|
+
var m;
|
909
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
910
|
+
while (1) {
|
911
|
+
switch (_context.prev = _context.next) {
|
912
|
+
case 0:
|
913
|
+
_context.next = 2;
|
914
|
+
return new Promise(function (resolve) {
|
915
|
+
_this3._connection.message.emit(MessageSocketEvent.CREATE, {
|
916
|
+
message: _extends({}, message, {
|
917
|
+
action: _this3._action.getData()
|
918
|
+
}),
|
919
|
+
channel: _this3._message.channel,
|
920
|
+
member: _this3.worker.botMember,
|
921
|
+
memberId: _this3.worker.botMember.memberId
|
922
|
+
}, function (m) {
|
923
|
+
return resolve(m);
|
924
|
+
});
|
925
|
+
});
|
926
|
+
|
927
|
+
case 2:
|
928
|
+
m = _context.sent;
|
929
|
+
this.updateAction(m.action);
|
930
|
+
return _context.abrupt("return", this.clone().setMessage(m));
|
931
|
+
|
932
|
+
case 5:
|
933
|
+
case "end":
|
934
|
+
return _context.stop();
|
935
|
+
}
|
936
|
+
}
|
937
|
+
}, _callee, this);
|
938
|
+
}));
|
939
|
+
|
940
|
+
function send(_x) {
|
941
|
+
return _send.apply(this, arguments);
|
942
|
+
}
|
943
|
+
|
944
|
+
return send;
|
945
|
+
}();
|
946
|
+
|
947
|
+
_proto.edit = /*#__PURE__*/function () {
|
948
|
+
var _edit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(message) {
|
949
|
+
var _this4 = this;
|
950
|
+
|
951
|
+
var m;
|
952
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
953
|
+
while (1) {
|
954
|
+
switch (_context2.prev = _context2.next) {
|
955
|
+
case 0:
|
956
|
+
_context2.next = 2;
|
957
|
+
return new Promise(function (resolve) {
|
958
|
+
var _message$action;
|
959
|
+
|
960
|
+
_this4._connection.message.emit(MessageSocketEvent.UPDATE, {
|
961
|
+
message: _extends({}, message, {
|
962
|
+
action: (_message$action = message.action) == null ? void 0 : _message$action.getData(),
|
963
|
+
messageId: _this4._message.messageId
|
964
|
+
}),
|
965
|
+
memberId: _this4.worker.botMember.memberId
|
966
|
+
}, function (m) {
|
967
|
+
return resolve(m);
|
968
|
+
});
|
969
|
+
});
|
970
|
+
|
971
|
+
case 2:
|
972
|
+
m = _context2.sent;
|
973
|
+
this.updateAction(m.action);
|
974
|
+
return _context2.abrupt("return", this.clone().setMessage(m));
|
975
|
+
|
976
|
+
case 5:
|
977
|
+
case "end":
|
978
|
+
return _context2.stop();
|
979
|
+
}
|
980
|
+
}
|
981
|
+
}, _callee2, this);
|
982
|
+
}));
|
983
|
+
|
984
|
+
function edit(_x2) {
|
985
|
+
return _edit.apply(this, arguments);
|
986
|
+
}
|
987
|
+
|
988
|
+
return edit;
|
989
|
+
}();
|
990
|
+
|
991
|
+
_proto.reply = /*#__PURE__*/function () {
|
992
|
+
var _reply = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(message) {
|
993
|
+
var _this5 = this;
|
994
|
+
|
995
|
+
var m;
|
996
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
997
|
+
while (1) {
|
998
|
+
switch (_context3.prev = _context3.next) {
|
999
|
+
case 0:
|
1000
|
+
_context3.next = 2;
|
1001
|
+
return new Promise(function (resolve) {
|
1002
|
+
var _message$action2;
|
1003
|
+
|
1004
|
+
_this5._connection.message.emit(MessageSocketEvent.CREATE, {
|
1005
|
+
message: _extends({}, message, {
|
1006
|
+
action: (_message$action2 = message.action) == null ? void 0 : _message$action2.getData(),
|
1007
|
+
messageId: _this5._message.messageId
|
1008
|
+
}),
|
1009
|
+
member: _this5.worker.botMember,
|
1010
|
+
replyTo: _this5._message.messageId,
|
1011
|
+
memberId: _this5.worker.botMember.memberId
|
1012
|
+
}, function (m) {
|
1013
|
+
return resolve(m);
|
1014
|
+
});
|
1015
|
+
});
|
1016
|
+
|
1017
|
+
case 2:
|
1018
|
+
m = _context3.sent;
|
1019
|
+
this.updateAction(m.action);
|
1020
|
+
return _context3.abrupt("return", this.clone().setMessage(m));
|
1021
|
+
|
1022
|
+
case 5:
|
1023
|
+
case "end":
|
1024
|
+
return _context3.stop();
|
1025
|
+
}
|
1026
|
+
}
|
1027
|
+
}, _callee3, this);
|
1028
|
+
}));
|
1029
|
+
|
1030
|
+
function reply(_x3) {
|
1031
|
+
return _reply.apply(this, arguments);
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
return reply;
|
1035
|
+
}();
|
1036
|
+
|
1037
|
+
_proto.setMessage = function setMessage(message) {
|
1038
|
+
this._message = message;
|
1039
|
+
return this;
|
1040
|
+
};
|
1041
|
+
|
1042
|
+
_proto.setAction = function setAction(action) {
|
1043
|
+
this._action = action;
|
1044
|
+
};
|
1045
|
+
|
1046
|
+
_proto.updateAction = function updateAction(action) {
|
1047
|
+
this._action.setId(action.actionId).setConnection(this._connection);
|
1048
|
+
};
|
1049
|
+
|
1050
|
+
_proto.clone = function clone() {
|
1051
|
+
var newService = new MessageService(this._client, this._connection);
|
1052
|
+
newService.setWorker(this.worker);
|
1053
|
+
newService.setMessage(this._message);
|
1054
|
+
newService._action = this._action;
|
1055
|
+
return newService;
|
1056
|
+
};
|
1057
|
+
|
1058
|
+
_createClass(MessageService, [{
|
1059
|
+
key: "data",
|
1060
|
+
get: function get() {
|
1061
|
+
if (!this._message) throw new Error('Message is not initialized');
|
1062
|
+
return this._message;
|
1063
|
+
}
|
1064
|
+
}, {
|
1065
|
+
key: "command",
|
1066
|
+
get: function get() {
|
1067
|
+
return this._inspectedCommand;
|
1068
|
+
}
|
1069
|
+
}, {
|
1070
|
+
key: "action",
|
1071
|
+
get: function get() {
|
1072
|
+
return this._action;
|
1073
|
+
}
|
1074
|
+
}]);
|
1075
|
+
|
1076
|
+
return MessageService;
|
1077
|
+
}(Service);
|
1078
|
+
|
1079
|
+
var MarkdownBuilder = /*#__PURE__*/function () {
|
1080
|
+
function MarkdownBuilder() {}
|
1081
|
+
|
1082
|
+
MarkdownBuilder.bold = function bold(text) {
|
1083
|
+
return "**" + text + "**";
|
1084
|
+
};
|
1085
|
+
|
1086
|
+
MarkdownBuilder.italic = function italic(text) {
|
1087
|
+
return "*" + text + "*";
|
1088
|
+
};
|
1089
|
+
|
1090
|
+
MarkdownBuilder.underline = function underline(text) {
|
1091
|
+
return "__" + text + "__";
|
1092
|
+
};
|
1093
|
+
|
1094
|
+
MarkdownBuilder.strikethrough = function strikethrough(text) {
|
1095
|
+
return "~~" + text + "~~";
|
1096
|
+
};
|
1097
|
+
|
1098
|
+
MarkdownBuilder.inlineCode = function inlineCode(text) {
|
1099
|
+
return "`" + text + "`";
|
1100
|
+
};
|
1101
|
+
|
1102
|
+
MarkdownBuilder.codeBlock = function codeBlock(text, language) {
|
1103
|
+
if (language) {
|
1104
|
+
return "```" + language + "\n" + text + "\n```";
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
return "```" + text + "```";
|
1108
|
+
};
|
1109
|
+
|
1110
|
+
MarkdownBuilder.link = function link(text, url) {
|
1111
|
+
return "[" + text + "](" + url + ")";
|
1112
|
+
};
|
1113
|
+
|
1114
|
+
MarkdownBuilder.image = function image(text, url) {
|
1115
|
+
return "";
|
1116
|
+
};
|
1117
|
+
|
1118
|
+
_createClass(MarkdownBuilder, null, [{
|
1119
|
+
key: "tag",
|
1120
|
+
get: function get() {
|
1121
|
+
return commonTags.stripIndent;
|
1122
|
+
}
|
1123
|
+
}]);
|
1124
|
+
|
1125
|
+
return MarkdownBuilder;
|
1126
|
+
}();
|
1127
|
+
|
1128
|
+
(function (ButtonStyle) {
|
1129
|
+
ButtonStyle["PRIMARY"] = "primary";
|
1130
|
+
ButtonStyle["SECONDARY"] = "secondary";
|
1131
|
+
ButtonStyle["SUCCESS"] = "success";
|
1132
|
+
ButtonStyle["WARNING"] = "warning";
|
1133
|
+
ButtonStyle["ERROR"] = "error";
|
1134
|
+
})(exports.ButtonStyle || (exports.ButtonStyle = {}));
|
1135
|
+
|
1136
|
+
var MessageButton = /*#__PURE__*/function () {
|
1137
|
+
function MessageButton() {}
|
1138
|
+
|
1139
|
+
var _proto = MessageButton.prototype;
|
1140
|
+
|
1141
|
+
_proto.setName = function setName(name) {
|
1142
|
+
this._name = name;
|
1143
|
+
return this;
|
1144
|
+
};
|
1145
|
+
|
1146
|
+
_proto.setCustomId = function setCustomId(customId) {
|
1147
|
+
this._customId = customId;
|
1148
|
+
return this;
|
1149
|
+
};
|
1150
|
+
|
1151
|
+
_proto.setDisabled = function setDisabled(disabled) {
|
1152
|
+
this._isDisabled = disabled;
|
1153
|
+
return this;
|
1154
|
+
};
|
1155
|
+
|
1156
|
+
_proto.setStyle = function setStyle(style) {
|
1157
|
+
this._style = style;
|
1158
|
+
return this;
|
1159
|
+
};
|
1160
|
+
|
1161
|
+
_proto.getData = function getData() {
|
1162
|
+
return {
|
1163
|
+
name: this._name,
|
1164
|
+
customId: this._customId,
|
1165
|
+
isDisabled: this._isDisabled,
|
1166
|
+
style: this._style
|
1167
|
+
};
|
1168
|
+
};
|
1169
|
+
|
1170
|
+
_createClass(MessageButton, [{
|
1171
|
+
key: "name",
|
1172
|
+
get: function get() {
|
1173
|
+
return this._name;
|
1174
|
+
}
|
1175
|
+
}, {
|
1176
|
+
key: "customId",
|
1177
|
+
get: function get() {
|
1178
|
+
return this._customId;
|
1179
|
+
}
|
1180
|
+
}, {
|
1181
|
+
key: "isDisabled",
|
1182
|
+
get: function get() {
|
1183
|
+
return this._isDisabled;
|
1184
|
+
}
|
1185
|
+
}, {
|
1186
|
+
key: "style",
|
1187
|
+
get: function get() {
|
1188
|
+
return this._style;
|
1189
|
+
}
|
1190
|
+
}]);
|
1191
|
+
|
1192
|
+
return MessageButton;
|
1193
|
+
}();
|
1194
|
+
|
1195
|
+
(function (SelectStyle) {
|
1196
|
+
SelectStyle["PRIMARY"] = "primary";
|
1197
|
+
SelectStyle["SECONDARY"] = "secondary";
|
1198
|
+
})(exports.SelectStyle || (exports.SelectStyle = {}));
|
1199
|
+
|
1200
|
+
var MessageSelect = /*#__PURE__*/function () {
|
1201
|
+
function MessageSelect() {
|
1202
|
+
this._options = [];
|
1203
|
+
}
|
1204
|
+
|
1205
|
+
var _proto = MessageSelect.prototype;
|
1206
|
+
|
1207
|
+
_proto.clearOption = function clearOption() {
|
1208
|
+
this._options = [];
|
1209
|
+
return this;
|
1210
|
+
};
|
1211
|
+
|
1212
|
+
_proto.addOption = function addOption(option) {
|
1213
|
+
this._options.push(option.getData());
|
1214
|
+
|
1215
|
+
return this;
|
1216
|
+
};
|
1217
|
+
|
1218
|
+
_proto.addOptions = function addOptions(options) {
|
1219
|
+
this._options = this._options.concat(options.map(function (option) {
|
1220
|
+
return option.getData();
|
1221
|
+
}));
|
1222
|
+
return this;
|
1223
|
+
};
|
1224
|
+
|
1225
|
+
_proto.setDisabled = function setDisabled(disabled) {
|
1226
|
+
this._isDisabled = disabled;
|
1227
|
+
return this;
|
1228
|
+
};
|
1229
|
+
|
1230
|
+
_proto.setStyle = function setStyle(style) {
|
1231
|
+
this._style = style;
|
1232
|
+
return this;
|
1233
|
+
};
|
1234
|
+
|
1235
|
+
_proto.setCustomId = function setCustomId(customId) {
|
1236
|
+
this._customId = customId;
|
1237
|
+
return this;
|
1238
|
+
};
|
1239
|
+
|
1240
|
+
_proto.getData = function getData() {
|
1241
|
+
return {
|
1242
|
+
customId: this._customId,
|
1243
|
+
isDisabled: this._isDisabled,
|
1244
|
+
style: this._style,
|
1245
|
+
options: this._options
|
1246
|
+
};
|
1247
|
+
};
|
1248
|
+
|
1249
|
+
_createClass(MessageSelect, [{
|
1250
|
+
key: "customId",
|
1251
|
+
get: function get() {
|
1252
|
+
return this._customId;
|
1253
|
+
}
|
1254
|
+
}, {
|
1255
|
+
key: "isDisabled",
|
1256
|
+
get: function get() {
|
1257
|
+
return this._isDisabled;
|
1258
|
+
}
|
1259
|
+
}, {
|
1260
|
+
key: "style",
|
1261
|
+
get: function get() {
|
1262
|
+
return this._style;
|
1263
|
+
}
|
1264
|
+
}, {
|
1265
|
+
key: "options",
|
1266
|
+
get: function get() {
|
1267
|
+
return this._options;
|
1268
|
+
}
|
1269
|
+
}]);
|
1270
|
+
|
1271
|
+
return MessageSelect;
|
1272
|
+
}();
|
1273
|
+
var MessageSelectOption = /*#__PURE__*/function () {
|
1274
|
+
function MessageSelectOption() {}
|
1275
|
+
|
1276
|
+
var _proto2 = MessageSelectOption.prototype;
|
1277
|
+
|
1278
|
+
_proto2.setDescription = function setDescription(description) {
|
1279
|
+
this._description = description;
|
1280
|
+
return this;
|
1281
|
+
};
|
1282
|
+
|
1283
|
+
_proto2.setValue = function setValue(value) {
|
1284
|
+
this._value = value;
|
1285
|
+
return this;
|
1286
|
+
};
|
1287
|
+
|
1288
|
+
_proto2.getData = function getData() {
|
1289
|
+
return {
|
1290
|
+
description: this._description,
|
1291
|
+
value: this._value
|
1292
|
+
};
|
1293
|
+
};
|
1294
|
+
|
1295
|
+
_createClass(MessageSelectOption, [{
|
1296
|
+
key: "description",
|
1297
|
+
get: function get() {
|
1298
|
+
return this._description;
|
1299
|
+
}
|
1300
|
+
}, {
|
1301
|
+
key: "value",
|
1302
|
+
get: function get() {
|
1303
|
+
return this._value;
|
1304
|
+
}
|
1305
|
+
}]);
|
1306
|
+
|
1307
|
+
return MessageSelectOption;
|
1308
|
+
}();
|
1309
|
+
|
1310
|
+
var ChannelService = /*#__PURE__*/function (_Service) {
|
1311
|
+
_inheritsLoose(ChannelService, _Service);
|
1312
|
+
|
1313
|
+
function ChannelService(_client, _connection) {
|
1314
|
+
var _this;
|
1315
|
+
|
1316
|
+
_this = _Service.call(this) || this;
|
1317
|
+
_this._client = _client;
|
1318
|
+
_this._connection = _connection;
|
1319
|
+
_this._route = _client.bot.info.botId + "/message";
|
1320
|
+
return _this;
|
1321
|
+
}
|
1322
|
+
|
1323
|
+
var _proto = ChannelService.prototype;
|
1324
|
+
|
1325
|
+
_proto.withIdOrName = function withIdOrName(channelNameOrId) {
|
1326
|
+
var existChannel = this.worker.guild.categories.map(function (c) {
|
1327
|
+
return c.channels;
|
1328
|
+
}).flat().find(function (c) {
|
1329
|
+
return c.name.toLowerCase() === channelNameOrId.toLowerCase() || c.channelId === channelNameOrId;
|
1330
|
+
});
|
1331
|
+
|
1332
|
+
if (!existChannel) {
|
1333
|
+
throw new Error('Channel not found');
|
1334
|
+
}
|
1335
|
+
|
1336
|
+
var newService = this.clone();
|
1337
|
+
newService.setChannel(existChannel);
|
1338
|
+
return newService;
|
1339
|
+
};
|
1340
|
+
|
1341
|
+
_proto.update = /*#__PURE__*/function () {
|
1342
|
+
var _update = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(channel) {
|
1343
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1344
|
+
while (1) {
|
1345
|
+
switch (_context.prev = _context.next) {
|
1346
|
+
case 0:
|
1347
|
+
this._connection.channel.emit(ChannelSocketEvent.UPDATE, {
|
1348
|
+
channel: _extends({
|
1349
|
+
channelId: this._channel.channelId
|
1350
|
+
}, channel),
|
1351
|
+
memberId: this.worker.botMember.memberId
|
1352
|
+
});
|
1353
|
+
|
1354
|
+
case 1:
|
1355
|
+
case "end":
|
1356
|
+
return _context.stop();
|
1357
|
+
}
|
1358
|
+
}
|
1359
|
+
}, _callee, this);
|
1360
|
+
}));
|
1361
|
+
|
1362
|
+
function update(_x) {
|
1363
|
+
return _update.apply(this, arguments);
|
1364
|
+
}
|
1365
|
+
|
1366
|
+
return update;
|
1367
|
+
}();
|
1368
|
+
|
1369
|
+
_proto.addMember = /*#__PURE__*/function () {
|
1370
|
+
var _addMember = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(memberNicknameOrId) {
|
1371
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1372
|
+
while (1) {
|
1373
|
+
switch (_context2.prev = _context2.next) {
|
1374
|
+
case 0:
|
1375
|
+
_context2.next = 2;
|
1376
|
+
return this.updateMemberOfChannel(ChannelSocketEvent.ADD_MEMBER, this._channel.channelId, memberNicknameOrId);
|
1377
|
+
|
1378
|
+
case 2:
|
1379
|
+
case "end":
|
1380
|
+
return _context2.stop();
|
1381
|
+
}
|
1382
|
+
}
|
1383
|
+
}, _callee2, this);
|
1384
|
+
}));
|
1385
|
+
|
1386
|
+
function addMember(_x2) {
|
1387
|
+
return _addMember.apply(this, arguments);
|
1388
|
+
}
|
1389
|
+
|
1390
|
+
return addMember;
|
1391
|
+
}();
|
1392
|
+
|
1393
|
+
_proto.removeMember = /*#__PURE__*/function () {
|
1394
|
+
var _removeMember = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(memberNicknameOrId) {
|
1395
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
1396
|
+
while (1) {
|
1397
|
+
switch (_context3.prev = _context3.next) {
|
1398
|
+
case 0:
|
1399
|
+
_context3.next = 2;
|
1400
|
+
return this.updateMemberOfChannel(ChannelSocketEvent.REMOVE_MEMBER, this._channel.channelId, memberNicknameOrId);
|
1401
|
+
|
1402
|
+
case 2:
|
1403
|
+
case "end":
|
1404
|
+
return _context3.stop();
|
1405
|
+
}
|
1406
|
+
}
|
1407
|
+
}, _callee3, this);
|
1408
|
+
}));
|
1409
|
+
|
1410
|
+
function removeMember(_x3) {
|
1411
|
+
return _removeMember.apply(this, arguments);
|
1412
|
+
}
|
1413
|
+
|
1414
|
+
return removeMember;
|
1415
|
+
}();
|
1416
|
+
|
1417
|
+
_proto.addRole = /*#__PURE__*/function () {
|
1418
|
+
var _addRole = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(roleNameOrId) {
|
1419
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
1420
|
+
while (1) {
|
1421
|
+
switch (_context4.prev = _context4.next) {
|
1422
|
+
case 0:
|
1423
|
+
_context4.next = 2;
|
1424
|
+
return this.updateRoleOfChannel(RoleSocketEvent.ADD_TO_CHANNEL, this._channel.channelId, roleNameOrId);
|
1425
|
+
|
1426
|
+
case 2:
|
1427
|
+
case "end":
|
1428
|
+
return _context4.stop();
|
1429
|
+
}
|
1430
|
+
}
|
1431
|
+
}, _callee4, this);
|
1432
|
+
}));
|
1433
|
+
|
1434
|
+
function addRole(_x4) {
|
1435
|
+
return _addRole.apply(this, arguments);
|
1436
|
+
}
|
1437
|
+
|
1438
|
+
return addRole;
|
1439
|
+
}();
|
1440
|
+
|
1441
|
+
_proto.removeRole = /*#__PURE__*/function () {
|
1442
|
+
var _removeRole = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(roleNameOrId) {
|
1443
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
1444
|
+
while (1) {
|
1445
|
+
switch (_context5.prev = _context5.next) {
|
1446
|
+
case 0:
|
1447
|
+
_context5.next = 2;
|
1448
|
+
return this.updateRoleOfChannel(RoleSocketEvent.REMOVE_FROM_CHANNEL, this._channel.channelId, roleNameOrId);
|
1449
|
+
|
1450
|
+
case 2:
|
1451
|
+
case "end":
|
1452
|
+
return _context5.stop();
|
1453
|
+
}
|
1454
|
+
}
|
1455
|
+
}, _callee5, this);
|
1456
|
+
}));
|
1457
|
+
|
1458
|
+
function removeRole(_x5) {
|
1459
|
+
return _removeRole.apply(this, arguments);
|
1460
|
+
}
|
1461
|
+
|
1462
|
+
return removeRole;
|
1463
|
+
}();
|
1464
|
+
|
1465
|
+
_proto.setChannel = function setChannel(channel) {
|
1466
|
+
this._channel = channel;
|
1467
|
+
};
|
1468
|
+
|
1469
|
+
_proto.inCategory = function inCategory(categoryNameOrId) {
|
1470
|
+
var _this2 = this;
|
1471
|
+
|
1472
|
+
var category = this.worker.guild.categories.find(function (c) {
|
1473
|
+
return c.name.toLowerCase() === categoryNameOrId.toLowerCase() || c.categoryId === categoryNameOrId;
|
1474
|
+
});
|
1475
|
+
|
1476
|
+
if (!category) {
|
1477
|
+
throw new Error('Category not found');
|
1478
|
+
}
|
1479
|
+
|
1480
|
+
return {
|
1481
|
+
create: function create(channel) {
|
1482
|
+
_this2._connection.channel.emit('create', {
|
1483
|
+
channel: channel,
|
1484
|
+
category: category,
|
1485
|
+
firstMember: _this2.worker.botMember,
|
1486
|
+
memberId: _this2.worker.botMember.memberId
|
1487
|
+
});
|
1488
|
+
}
|
1489
|
+
};
|
1490
|
+
};
|
1491
|
+
|
1492
|
+
_proto.clone = function clone() {
|
1493
|
+
var newService = new ChannelService(this._client, this._connection);
|
1494
|
+
newService.setChannel(this._channel);
|
1495
|
+
newService.setWorker(this.worker);
|
1496
|
+
return newService;
|
1497
|
+
};
|
1498
|
+
|
1499
|
+
_proto.updateMemberOfChannel = /*#__PURE__*/function () {
|
1500
|
+
var _updateMemberOfChannel = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(event, channelId, memberNicknameOrId) {
|
1501
|
+
var existMember;
|
1502
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
1503
|
+
while (1) {
|
1504
|
+
switch (_context6.prev = _context6.next) {
|
1505
|
+
case 0:
|
1506
|
+
existMember = this.worker.guild.members.find(function (m) {
|
1507
|
+
return m.nickname.toLowerCase() === memberNicknameOrId.toLowerCase() || m.memberId === memberNicknameOrId;
|
1508
|
+
});
|
1509
|
+
|
1510
|
+
if (existMember) {
|
1511
|
+
_context6.next = 3;
|
1512
|
+
break;
|
1513
|
+
}
|
1514
|
+
|
1515
|
+
throw new Error('Member not found');
|
1516
|
+
|
1517
|
+
case 3:
|
1518
|
+
this._connection.channel.emit(event, {
|
1519
|
+
channel: {
|
1520
|
+
channelId: channelId,
|
1521
|
+
memberId: existMember.memberId
|
1522
|
+
},
|
1523
|
+
memberId: this.worker.botMember.memberId
|
1524
|
+
});
|
1525
|
+
|
1526
|
+
case 4:
|
1527
|
+
case "end":
|
1528
|
+
return _context6.stop();
|
1529
|
+
}
|
1530
|
+
}
|
1531
|
+
}, _callee6, this);
|
1532
|
+
}));
|
1533
|
+
|
1534
|
+
function updateMemberOfChannel(_x6, _x7, _x8) {
|
1535
|
+
return _updateMemberOfChannel.apply(this, arguments);
|
1536
|
+
}
|
1537
|
+
|
1538
|
+
return updateMemberOfChannel;
|
1539
|
+
}();
|
1540
|
+
|
1541
|
+
_proto.updateRoleOfChannel = /*#__PURE__*/function () {
|
1542
|
+
var _updateRoleOfChannel = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(event, channelId, roleNameOrId) {
|
1543
|
+
var existRole;
|
1544
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
1545
|
+
while (1) {
|
1546
|
+
switch (_context7.prev = _context7.next) {
|
1547
|
+
case 0:
|
1548
|
+
existRole = this.worker.guild.roles.find(function (r) {
|
1549
|
+
return r.name.toLowerCase() === roleNameOrId.toLowerCase() || r.roleId === roleNameOrId;
|
1550
|
+
});
|
1551
|
+
|
1552
|
+
if (existRole) {
|
1553
|
+
_context7.next = 3;
|
1554
|
+
break;
|
1555
|
+
}
|
1556
|
+
|
1557
|
+
throw new Error('Role not found');
|
1558
|
+
|
1559
|
+
case 3:
|
1560
|
+
this._connection.role.emit(event, {
|
1561
|
+
channel: {
|
1562
|
+
channelId: channelId,
|
1563
|
+
roleId: existRole.roleId
|
1564
|
+
},
|
1565
|
+
memberId: this.worker.botMember.memberId
|
1566
|
+
});
|
1567
|
+
|
1568
|
+
case 4:
|
1569
|
+
case "end":
|
1570
|
+
return _context7.stop();
|
1571
|
+
}
|
1572
|
+
}
|
1573
|
+
}, _callee7, this);
|
1574
|
+
}));
|
1575
|
+
|
1576
|
+
function updateRoleOfChannel(_x9, _x10, _x11) {
|
1577
|
+
return _updateRoleOfChannel.apply(this, arguments);
|
1578
|
+
}
|
1579
|
+
|
1580
|
+
return updateRoleOfChannel;
|
1581
|
+
}();
|
1582
|
+
|
1583
|
+
_createClass(ChannelService, [{
|
1584
|
+
key: "data",
|
1585
|
+
get: function get() {
|
1586
|
+
if (!this._channel) throw new Error('Channel is not initialized');
|
1587
|
+
return this._channel;
|
1588
|
+
}
|
1589
|
+
}]);
|
1590
|
+
|
1591
|
+
return ChannelService;
|
1592
|
+
}(Service);
|
1593
|
+
|
1594
|
+
var Config = function Config() {};
|
1595
|
+
Config.SERVER_HOST = 'https://c522-116-102-222-20.ap.ngrok.io';
|
1596
|
+
|
1597
|
+
(function (FriendStatus) {
|
1598
|
+
FriendStatus["ACCEPTED"] = "accepted";
|
1599
|
+
FriendStatus["PENDING"] = "pending";
|
1600
|
+
FriendStatus["BLOCKED"] = "blocked";
|
1601
|
+
})(exports.FriendStatus || (exports.FriendStatus = {}));
|
1602
|
+
|
1603
|
+
var BotInfo = /*#__PURE__*/function () {
|
1604
|
+
function BotInfo(_connection) {
|
1605
|
+
this._connection = _connection;
|
1606
|
+
}
|
1607
|
+
|
1608
|
+
var _proto = BotInfo.prototype;
|
1609
|
+
|
1610
|
+
_proto.getInfo = /*#__PURE__*/function () {
|
1611
|
+
var _getInfo = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(token) {
|
1612
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1613
|
+
while (1) {
|
1614
|
+
switch (_context.prev = _context.next) {
|
1615
|
+
case 0:
|
1616
|
+
_context.prev = 0;
|
1617
|
+
_context.next = 3;
|
1618
|
+
return axios.get(Config.SERVER_HOST + "/bot", {
|
1619
|
+
headers: {
|
1620
|
+
Authorization: "Bearer " + token
|
1621
|
+
}
|
1622
|
+
});
|
1623
|
+
|
1624
|
+
case 3:
|
1625
|
+
this._info = _context.sent.data;
|
1626
|
+
_context.next = 9;
|
1627
|
+
break;
|
1628
|
+
|
1629
|
+
case 6:
|
1630
|
+
_context.prev = 6;
|
1631
|
+
_context.t0 = _context["catch"](0);
|
1632
|
+
throw new Error('Token is invalid or expired');
|
1633
|
+
|
1634
|
+
case 9:
|
1635
|
+
case "end":
|
1636
|
+
return _context.stop();
|
1637
|
+
}
|
1638
|
+
}
|
1639
|
+
}, _callee, this, [[0, 6]]);
|
1640
|
+
}));
|
1641
|
+
|
1642
|
+
function getInfo(_x) {
|
1643
|
+
return _getInfo.apply(this, arguments);
|
1644
|
+
}
|
1645
|
+
|
1646
|
+
return getInfo;
|
1647
|
+
}();
|
1648
|
+
|
1649
|
+
_proto.listenUpdate = function listenUpdate() {
|
1650
|
+
var _this = this;
|
1651
|
+
|
1652
|
+
this._connection.member.on(this._info.botId + "/" + SocketNamespace.MEMBER + "/" + MemberSocketEmit.JOIN, function (member) {
|
1653
|
+
_this._info.joinedGuilds.push(member);
|
1654
|
+
});
|
1655
|
+
|
1656
|
+
this._connection.member.on(this._info.botId + "/" + SocketNamespace.MEMBER + "/" + MemberSocketEmit.LEAVE, function (member) {
|
1657
|
+
_this._info.joinedGuilds = _this._info.joinedGuilds.filter(function (m) {
|
1658
|
+
return m.memberId !== member.memberId;
|
1659
|
+
});
|
1660
|
+
});
|
1661
|
+
};
|
1662
|
+
|
1663
|
+
_createClass(BotInfo, [{
|
1664
|
+
key: "info",
|
1665
|
+
get: function get() {
|
1666
|
+
return this._info;
|
1667
|
+
}
|
1668
|
+
}]);
|
1669
|
+
|
1670
|
+
return BotInfo;
|
1671
|
+
}();
|
1672
|
+
|
1673
|
+
var Connection = function Connection(gateway) {
|
1674
|
+
this.message = gateway.socket("/" + SocketNamespace.MESSAGE);
|
1675
|
+
this.channel = gateway.socket("/" + SocketNamespace.CHANNEL);
|
1676
|
+
this.role = gateway.socket("/" + SocketNamespace.ROLE);
|
1677
|
+
this.member = gateway.socket("/" + SocketNamespace.MEMBER);
|
1678
|
+
this.action = gateway.socket("/" + SocketNamespace.ACTION);
|
1679
|
+
this.button = gateway.socket("/" + SocketNamespace.BUTTON);
|
1680
|
+
this.react = gateway.socket("/" + SocketNamespace.REACT);
|
1681
|
+
this.select = gateway.socket("/" + SocketNamespace.SELECT);
|
1682
|
+
};
|
1683
|
+
|
1684
|
+
var Client = /*#__PURE__*/function () {
|
1685
|
+
function Client() {}
|
1686
|
+
|
1687
|
+
var _proto = Client.prototype;
|
1688
|
+
|
1689
|
+
_proto.login = /*#__PURE__*/function () {
|
1690
|
+
var _login = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(token) {
|
1691
|
+
var _iterator, _step, command;
|
1692
|
+
|
1693
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1694
|
+
while (1) {
|
1695
|
+
switch (_context.prev = _context.next) {
|
1696
|
+
case 0:
|
1697
|
+
_context.prev = 0;
|
1698
|
+
this._accessToken = token;
|
1699
|
+
this._gateway = new socket_ioClient.Manager(Config.SERVER_HOST, {
|
1700
|
+
transportOptions: {
|
1701
|
+
polling: {
|
1702
|
+
extraHeaders: {
|
1703
|
+
authorization: "Bearer " + this._accessToken
|
1704
|
+
}
|
1705
|
+
}
|
1706
|
+
}
|
1707
|
+
});
|
1708
|
+
this._connection = new Connection(this._gateway);
|
1709
|
+
this._bot = new BotInfo(this._connection);
|
1710
|
+
_context.next = 7;
|
1711
|
+
return this._bot.getInfo(this._accessToken);
|
1712
|
+
|
1713
|
+
case 7:
|
1714
|
+
this._bot.listenUpdate();
|
1715
|
+
|
1716
|
+
this._messageService = new MessageService(this, this._connection);
|
1717
|
+
this._channalService = new ChannelService(this, this._connection);
|
1718
|
+
console.log('💖 Login successfully'); //validate commands which user created to bot manager
|
1719
|
+
|
1720
|
+
_iterator = _createForOfIteratorHelperLoose(this._bot.info.commands);
|
1721
|
+
|
1722
|
+
case 12:
|
1723
|
+
if ((_step = _iterator()).done) {
|
1724
|
+
_context.next = 18;
|
1725
|
+
break;
|
1726
|
+
}
|
1727
|
+
|
1728
|
+
command = _step.value;
|
1729
|
+
|
1730
|
+
if (this[command.name]) {
|
1731
|
+
_context.next = 16;
|
1732
|
+
break;
|
1733
|
+
}
|
1734
|
+
|
1735
|
+
throw new Error(this._bot.info.name + ".[" + command.name + "] command is not implemented");
|
1736
|
+
|
1737
|
+
case 16:
|
1738
|
+
_context.next = 12;
|
1739
|
+
break;
|
1740
|
+
|
1741
|
+
case 18:
|
1742
|
+
_context.next = 23;
|
1743
|
+
break;
|
1744
|
+
|
1745
|
+
case 20:
|
1746
|
+
_context.prev = 20;
|
1747
|
+
_context.t0 = _context["catch"](0);
|
1748
|
+
console.error(_context.t0);
|
1749
|
+
|
1750
|
+
case 23:
|
1751
|
+
case "end":
|
1752
|
+
return _context.stop();
|
1753
|
+
}
|
1754
|
+
}
|
1755
|
+
}, _callee, this, [[0, 20]]);
|
1756
|
+
}));
|
1757
|
+
|
1758
|
+
function login(_x) {
|
1759
|
+
return _login.apply(this, arguments);
|
1760
|
+
}
|
1761
|
+
|
1762
|
+
return login;
|
1763
|
+
}()
|
1764
|
+
/**@return message received: MessageEntity */
|
1765
|
+
;
|
1766
|
+
|
1767
|
+
_createClass(Client, [{
|
1768
|
+
key: "message",
|
1769
|
+
get: function get() {
|
1770
|
+
if (!this._messageService) throw new Error('Message Service is not initialized');
|
1771
|
+
return this._messageService;
|
1772
|
+
},
|
1773
|
+
set: function set(messageService) {
|
1774
|
+
this._messageService = messageService;
|
1775
|
+
}
|
1776
|
+
/**@return channel which received message: ChannelEntity */
|
1777
|
+
|
1778
|
+
}, {
|
1779
|
+
key: "channel",
|
1780
|
+
get: function get() {
|
1781
|
+
if (!this._channalService) throw new Error('Channel Service is not initialized');
|
1782
|
+
return this._channalService;
|
1783
|
+
}
|
1784
|
+
/**@return currentBot: BotEntity */
|
1785
|
+
|
1786
|
+
}, {
|
1787
|
+
key: "bot",
|
1788
|
+
get: function get() {
|
1789
|
+
if (!this._bot) throw new Error('Bot is not identified');
|
1790
|
+
return this._bot;
|
1791
|
+
}
|
1792
|
+
}]);
|
1793
|
+
|
1794
|
+
return Client;
|
1795
|
+
}();
|
1796
|
+
|
1797
|
+
var MessageClient = /*#__PURE__*/function (_Client) {
|
1798
|
+
_inheritsLoose(MessageClient, _Client);
|
1799
|
+
|
1800
|
+
function MessageClient() {
|
1801
|
+
return _Client.apply(this, arguments) || this;
|
1802
|
+
}
|
1803
|
+
|
1804
|
+
var _proto = MessageClient.prototype;
|
1805
|
+
|
1806
|
+
_proto.login = /*#__PURE__*/function () {
|
1807
|
+
var _login = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(token) {
|
1808
|
+
var _this = this;
|
1809
|
+
|
1810
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1811
|
+
while (1) {
|
1812
|
+
switch (_context.prev = _context.next) {
|
1813
|
+
case 0:
|
1814
|
+
_context.next = 2;
|
1815
|
+
return _Client.prototype.login.call(this, token);
|
1816
|
+
|
1817
|
+
case 2:
|
1818
|
+
this.message.onCreate(function (_ref) {
|
1819
|
+
var worker = _ref.worker;
|
1820
|
+
|
1821
|
+
_this.message.setWorker(worker);
|
1822
|
+
|
1823
|
+
_this.message.setAction(new MessageAction());
|
1824
|
+
|
1825
|
+
_this.channel.setWorker(worker);
|
1826
|
+
|
1827
|
+
_this.channel.setChannel(_this.message.data.channel);
|
1828
|
+
|
1829
|
+
_this.bot.info.commands.forEach(function (command) {
|
1830
|
+
var _this$message$command = _this.message.command,
|
1831
|
+
name = _this$message$command.name,
|
1832
|
+
args = _this$message$command.args;
|
1833
|
+
|
1834
|
+
if (name && args && command.name === name && command.args.length === args.length) {
|
1835
|
+
_this[command.name].apply(_this, args);
|
1836
|
+
}
|
1837
|
+
});
|
1838
|
+
});
|
1839
|
+
|
1840
|
+
case 3:
|
1841
|
+
case "end":
|
1842
|
+
return _context.stop();
|
1843
|
+
}
|
1844
|
+
}
|
1845
|
+
}, _callee, this);
|
1846
|
+
}));
|
1847
|
+
|
1848
|
+
function login(_x) {
|
1849
|
+
return _login.apply(this, arguments);
|
1850
|
+
}
|
1851
|
+
|
1852
|
+
return login;
|
1853
|
+
}();
|
1854
|
+
|
1855
|
+
return MessageClient;
|
1856
|
+
}(Client);
|
1857
|
+
|
1858
|
+
exports.BotInfo = BotInfo;
|
1859
|
+
exports.ChannelService = ChannelService;
|
1860
|
+
exports.Client = Client;
|
1861
|
+
exports.Config = Config;
|
1862
|
+
exports.Connection = Connection;
|
1863
|
+
exports.MarkdownBuilder = MarkdownBuilder;
|
1864
|
+
exports.MessageAction = MessageAction;
|
1865
|
+
exports.MessageButton = MessageButton;
|
1866
|
+
exports.MessageClient = MessageClient;
|
1867
|
+
exports.MessageSelect = MessageSelect;
|
1868
|
+
exports.MessageSelectOption = MessageSelectOption;
|
1869
|
+
exports.MessageService = MessageService;
|
1870
|
+
exports.Service = Service;
|
1871
|
+
exports.Worker = Worker;
|
1872
|
+
//# sourceMappingURL=disney.js.cjs.development.js.map
|