@globalart/nestcord 1.3.11 → 1.3.12
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.
|
@@ -30,6 +30,7 @@ const schedule_1 = require("@nestjs/schedule");
|
|
|
30
30
|
const cron_1 = require("cron");
|
|
31
31
|
const axios_1 = require("@nestjs/axios");
|
|
32
32
|
const text_utils_1 = require("@globalart/text-utils");
|
|
33
|
+
const rxjs_1 = require("rxjs");
|
|
33
34
|
let NestCordStatReporterService = NestCordStatReporterService_1 = class NestCordStatReporterService {
|
|
34
35
|
constructor(client, shard, options, schedulerRegistry, httpService) {
|
|
35
36
|
this.client = client;
|
|
@@ -63,23 +64,26 @@ let NestCordStatReporterService = NestCordStatReporterService_1 = class NestCord
|
|
|
63
64
|
}
|
|
64
65
|
reportStats(service) {
|
|
65
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
var _a
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
67
|
+
var _a;
|
|
68
|
+
try {
|
|
69
|
+
const [_, serverCount, shardCount] = yield Promise.all([
|
|
70
|
+
this.client.application.fetch(),
|
|
71
|
+
this.calculateServerCount(),
|
|
72
|
+
Promise.resolve(((_a = this.shard) === null || _a === void 0 ? void 0 : _a.count) || 1),
|
|
73
|
+
]);
|
|
74
|
+
const bodyData = (0, text_utils_1.replacePlaceholdersInObject)(service.bodyData, { serverCount, shardCount });
|
|
75
|
+
const headerData = service.headerData || {};
|
|
76
|
+
yield (0, rxjs_1.lastValueFrom)(this.httpService.request({
|
|
77
|
+
method: service.method || 'POST',
|
|
78
|
+
url: service.url,
|
|
79
|
+
data: bodyData,
|
|
80
|
+
headers: headerData,
|
|
81
|
+
}));
|
|
82
|
+
this.logStats(service.name, serverCount, shardCount);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
this.logErrors(service.name, err);
|
|
86
|
+
}
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
89
|
calculateServerCount() {
|
|
@@ -98,6 +102,12 @@ let NestCordStatReporterService = NestCordStatReporterService_1 = class NestCord
|
|
|
98
102
|
this.logger.log(`Reporting stats for ${serviceName}, servers: ${serverCount}, shards: ${shardCount}`);
|
|
99
103
|
}
|
|
100
104
|
}
|
|
105
|
+
logErrors(serviceName, error) {
|
|
106
|
+
var _a;
|
|
107
|
+
if ((_a = this.options.log) !== null && _a !== void 0 ? _a : true) {
|
|
108
|
+
this.logger.error(`Error reporting stats for ${serviceName}`, error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
101
111
|
};
|
|
102
112
|
exports.NestCordStatReporterService = NestCordStatReporterService;
|
|
103
113
|
exports.NestCordStatReporterService = NestCordStatReporterService = NestCordStatReporterService_1 = __decorate([
|
package/package.json
CHANGED