apexify.js 2.4.4 → 3.0.0
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.
- package/README.md +4 -710
- package/dataSQL/data.sql +5 -0
- package/dataSQL/dataName.sql +0 -0
- package/dataSQL/example_table.sql +1 -0
- package/index.js +3 -78
- package/lib/ai/apexAI.js +2 -2
- package/lib/{discord/events/handler → ai/buttons}/tools.js +1 -1
- package/lib/utils.js +2 -72
- package/package.json +2 -81
- package/lib/canvas/themes/level ara.ttf +0 -0
- package/lib/canvas/themes/levelFont.ttf +0 -0
- package/lib/canvas/themes/levels-card.js +0 -884
- package/lib/canvas/themes/music-card.js +0 -342
- package/lib/canvas/themes/numbers.ttf +0 -0
- package/lib/canvas/themes/tajawal.ttf +0 -0
- package/lib/database/MongoDB.js +0 -126
- package/lib/database/NanoDB.js +0 -1341
- package/lib/database/mongoDb/aggregate.js +0 -120
- package/lib/database/mongoDb/countDocs.js +0 -115
- package/lib/database/mongoDb/createCollection.js +0 -125
- package/lib/database/mongoDb/dataSize.js +0 -89
- package/lib/database/mongoDb/distinct.js +0 -110
- package/lib/database/mongoDb/drop.js +0 -76
- package/lib/database/mongoDb/find.js +0 -122
- package/lib/database/mongoDb/geoNear.js +0 -91
- package/lib/database/mongoDb/index.js +0 -71
- package/lib/database/mongoDb/listCollections.js +0 -81
- package/lib/database/mongoDb/migrateAndPrune.js +0 -89
- package/lib/database/mongoDb/migrateData.js +0 -79
- package/lib/database/mongoDb/remove.js +0 -73
- package/lib/database/mongoDb/removeMany.js +0 -73
- package/lib/database/mongoDb/removeManyExcept.js +0 -91
- package/lib/database/mongoDb/removeSpecific.js +0 -93
- package/lib/database/mongoDb/save.js +0 -94
- package/lib/database/mongoDb/searchMany.js +0 -109
- package/lib/database/mongoDb/textSearch.js +0 -88
- package/lib/database/mongoDb/updateAll.js +0 -80
- package/lib/database/mongoDb/updateAllExcept.js +0 -108
- package/lib/database/mongoDb/updateData.js +0 -106
- package/lib/database/nanoDb/fetchData.js +0 -39
- package/lib/database/nanoDb/removeField.js +0 -46
- package/lib/database/nanoDb/saveData.js +0 -68
- package/lib/database/nanoDb/updateFilter.js +0 -24
- package/lib/database/ready-schemas.js +0 -245
- package/lib/database/utils.js +0 -58
- package/lib/discord/discord-build/commands-(prefix)/music/functions/buttons.js +0 -361
- package/lib/discord/discord-build/commands-(prefix)/music/functions/end.js +0 -58
- package/lib/discord/discord-build/commands-(prefix)/music/functions/start.js +0 -115
- package/lib/discord/discord-build/commands-(prefix)/music/play.js +0 -152
- package/lib/discord/discord-build/commands-(prefix)/music/previous.js +0 -82
- package/lib/discord/discord-build/commands-(prefix)/music/resume.js +0 -93
- package/lib/discord/discord-build/commands-(prefix)/music/skip.js +0 -82
- package/lib/discord/discord-build/commands-(prefix)/music/stop.js +0 -79
- package/lib/discord/discord-build/components/buttons.js +0 -75
- package/lib/discord/discord-build/components/menus.js +0 -81
- package/lib/discord/discord-build/components/paginator.js +0 -156
- package/lib/discord/discord-build/components/permsChecker.js +0 -81
- package/lib/discord/discord-build/levelingSystem/cLevel.js +0 -829
- package/lib/discord/discord-build/levelingSystem/cLevelsArray.json +0 -104
- package/lib/discord/discord-build/utils.js +0 -23
- package/lib/discord/events/eventer.js +0 -145
- package/lib/discord/events/prefixRegister.js +0 -148
- package/lib/discord/events/prefixResponder.js +0 -163
- package/lib/discord/events/slashRegister.js +0 -183
- package/lib/discord/events/slashResponder.js +0 -108
- package/lib/discord/events/starter.js +0 -441
- package/lib/discord/functions/perms.js +0 -19
- package/lib/discord/utils.js +0 -6
- package/lib/general-functions/discord/typeWriter.js +0 -77
- package/lib/general-functions/utils.js +0 -19
- /package/lib/{discord/events/handler → ai/buttons}/drawMenu.js +0 -0
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.updateAllExcept = void 0;
|
|
51
|
-
var { getDb } = require("../MongoDB");
|
|
52
|
-
function updateAllExcept(collectionName, filter, update, excludedKeys) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var db, documentsToUpdate, updatedDocuments, result, error_1;
|
|
55
|
-
return __generator(this, function (_a) {
|
|
56
|
-
switch (_a.label) {
|
|
57
|
-
case 0:
|
|
58
|
-
_a.trys.push([0, 4, , 5]);
|
|
59
|
-
return [4 /*yield*/, (0, getDb)()];
|
|
60
|
-
case 1:
|
|
61
|
-
db = _a.sent();
|
|
62
|
-
if (!db)
|
|
63
|
-
return [2 /*return*/, null];
|
|
64
|
-
if (typeof collectionName !== 'string') {
|
|
65
|
-
throw new Error('Invalid input. Collection name must be a string.');
|
|
66
|
-
}
|
|
67
|
-
if (typeof filter !== 'object' || filter === null || Array.isArray(filter)) {
|
|
68
|
-
throw new Error('Invalid input. Filter must be an object.');
|
|
69
|
-
}
|
|
70
|
-
if (typeof update !== 'object' || update === null || Array.isArray(update)) {
|
|
71
|
-
throw new Error('Invalid input. Update must be an object.');
|
|
72
|
-
}
|
|
73
|
-
if (!Array.isArray(excludedKeys)) {
|
|
74
|
-
throw new Error('Invalid input. Excluded keys must be an array.');
|
|
75
|
-
}
|
|
76
|
-
return [4 /*yield*/, db.collection(collectionName).find(filter).toArray()];
|
|
77
|
-
case 2:
|
|
78
|
-
documentsToUpdate = _a.sent();
|
|
79
|
-
updatedDocuments = documentsToUpdate.map(function (document) {
|
|
80
|
-
var updatedDocument = __assign({}, document);
|
|
81
|
-
excludedKeys.forEach(function (key) { return delete updatedDocument[key]; });
|
|
82
|
-
return __assign(__assign({}, updatedDocument), update);
|
|
83
|
-
});
|
|
84
|
-
return [4 /*yield*/, db.collection(collectionName).updateMany(filter, { $set: update })];
|
|
85
|
-
case 3:
|
|
86
|
-
result = _a.sent();
|
|
87
|
-
return [2 /*return*/, {
|
|
88
|
-
success: true,
|
|
89
|
-
message: "".concat(result.modifiedCount, " documents updated successfully."),
|
|
90
|
-
updatedDocuments: updatedDocuments,
|
|
91
|
-
result: result || null,
|
|
92
|
-
}];
|
|
93
|
-
case 4:
|
|
94
|
-
error_1 = _a.sent();
|
|
95
|
-
console.error('Error:', error_1.message);
|
|
96
|
-
return [2 /*return*/, {
|
|
97
|
-
success: false,
|
|
98
|
-
message: error_1.message,
|
|
99
|
-
updatedDocuments: null,
|
|
100
|
-
result: null,
|
|
101
|
-
}];
|
|
102
|
-
case 5: return [2 /*return*/];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
exports.updateAllExcept = updateAllExcept;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.updateData = void 0;
|
|
40
|
-
var { getDb } = require("../MongoDB");
|
|
41
|
-
function updateData(collectionName, filter, update, uniqueFields) {
|
|
42
|
-
if (uniqueFields === void 0) { uniqueFields = []; }
|
|
43
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
-
var db, _i, uniqueFields_1, field, existingDocument, updateOptions, result, updatedDocument, error_1;
|
|
45
|
-
var _a;
|
|
46
|
-
return __generator(this, function (_b) {
|
|
47
|
-
switch (_b.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
_b.trys.push([0, 8, , 9]);
|
|
50
|
-
return [4 /*yield*/, (0, getDb)()];
|
|
51
|
-
case 1:
|
|
52
|
-
db = _b.sent();
|
|
53
|
-
if (!db)
|
|
54
|
-
return [2 /*return*/, null];
|
|
55
|
-
if (typeof collectionName !== 'string' || !collectionName.trim()) {
|
|
56
|
-
throw new Error('Invalid input. Collection name must be provided as a non-empty string.');
|
|
57
|
-
}
|
|
58
|
-
if (!filter || typeof filter !== 'object' || Object.keys(filter).length === 0) {
|
|
59
|
-
throw new Error('Invalid input. Filter must be provided as a non-empty object.');
|
|
60
|
-
}
|
|
61
|
-
if (!update || typeof update !== 'object' || Object.keys(update).length === 0) {
|
|
62
|
-
throw new Error('Invalid input. Update must be provided as a non-empty object.');
|
|
63
|
-
}
|
|
64
|
-
if (!Array.isArray(uniqueFields)) {
|
|
65
|
-
throw new Error('Invalid input. Unique fields must be provided as an array.');
|
|
66
|
-
}
|
|
67
|
-
_i = 0, uniqueFields_1 = uniqueFields;
|
|
68
|
-
_b.label = 2;
|
|
69
|
-
case 2:
|
|
70
|
-
if (!(_i < uniqueFields_1.length)) return [3 /*break*/, 5];
|
|
71
|
-
field = uniqueFields_1[_i];
|
|
72
|
-
return [4 /*yield*/, db.collection(collectionName).findOne((_a = {}, _a[field] = update[field], _a._id = { $ne: filter._id }, _a))];
|
|
73
|
-
case 3:
|
|
74
|
-
existingDocument = _b.sent();
|
|
75
|
-
if (existingDocument) {
|
|
76
|
-
throw new Error("Document with the specified ".concat(field, " already exists. Please provide a unique value."));
|
|
77
|
-
}
|
|
78
|
-
_b.label = 4;
|
|
79
|
-
case 4:
|
|
80
|
-
_i++;
|
|
81
|
-
return [3 /*break*/, 2];
|
|
82
|
-
case 5:
|
|
83
|
-
updateOptions = { upsert: true };
|
|
84
|
-
return [4 /*yield*/, db.collection(collectionName).updateOne(filter, update, updateOptions)];
|
|
85
|
-
case 6:
|
|
86
|
-
result = _b.sent();
|
|
87
|
-
return [4 /*yield*/, db.collection(collectionName).findOne(filter)];
|
|
88
|
-
case 7:
|
|
89
|
-
updatedDocument = _b.sent();
|
|
90
|
-
return [2 /*return*/, {
|
|
91
|
-
success: true,
|
|
92
|
-
message: 'Document updated successfully.',
|
|
93
|
-
result: result || null,
|
|
94
|
-
data: updatedDocument,
|
|
95
|
-
}];
|
|
96
|
-
case 8:
|
|
97
|
-
error_1 = _b.sent();
|
|
98
|
-
console.error('Error updating document:', error_1);
|
|
99
|
-
throw new Error('Failed to update document in MongoDB');
|
|
100
|
-
case 9: return [2 /*return*/];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
exports.updateData = updateData;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.fetchData = void 0;
|
|
13
|
-
function fetchData(data, options) {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
let displayedData = [...data];
|
|
16
|
-
if (options && options.filters) {
|
|
17
|
-
const filterKeys = Object.keys(options.filters);
|
|
18
|
-
displayedData = displayedData.filter((item) => {
|
|
19
|
-
return filterKeys.every((key) => {
|
|
20
|
-
if (options.filters && options.filters[key] === true) {
|
|
21
|
-
return !!item[key];
|
|
22
|
-
}
|
|
23
|
-
else if (options.filters) {
|
|
24
|
-
return item[key] === options.filters[key];
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
if (options && options.displayment !== null) {
|
|
33
|
-
displayedData = options.displayment ? displayedData.slice(0, options.displayment) : displayedData;
|
|
34
|
-
}
|
|
35
|
-
return displayedData;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
exports.fetchData = fetchData;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matchesFilterQuery = exports.removeFields = void 0;
|
|
4
|
-
function removeFields(data, filterQuery, removeFilter) {
|
|
5
|
-
if (!Array.isArray(data)) {
|
|
6
|
-
throw new Error('Data must be an array of documents.');
|
|
7
|
-
}
|
|
8
|
-
if (typeof filterQuery !== 'object' || filterQuery === null) {
|
|
9
|
-
throw new Error('Filter query must be an object.');
|
|
10
|
-
}
|
|
11
|
-
if (typeof removeFilter !== 'object' || removeFilter === null || Object.keys(removeFilter).length === 0) {
|
|
12
|
-
throw new Error('Remove filter must be a non-empty object.');
|
|
13
|
-
}
|
|
14
|
-
const result = [...data];
|
|
15
|
-
if (Object.keys(filterQuery).length === 0) {
|
|
16
|
-
result.forEach((document) => {
|
|
17
|
-
removeFieldsFromDocument(document, removeFilter);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
const indexToUpdate = result.findIndex((document) => matchesFilterQuery(document, filterQuery));
|
|
22
|
-
if (indexToUpdate !== -1) {
|
|
23
|
-
removeFieldsFromDocument(result[indexToUpdate], removeFilter);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
exports.removeFields = removeFields;
|
|
29
|
-
function matchesFilterQuery(document, filterQuery) {
|
|
30
|
-
for (const key in filterQuery) {
|
|
31
|
-
if (filterQuery[key] !== 'any' && document[key] !== filterQuery[key]) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
exports.matchesFilterQuery = matchesFilterQuery;
|
|
39
|
-
|
|
40
|
-
function removeFieldsFromDocument(document, removeFilter) {
|
|
41
|
-
for (const field in removeFilter) {
|
|
42
|
-
if (document.hasOwnProperty(field)) {
|
|
43
|
-
delete document[field];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.saveData = void 0;
|
|
13
|
-
const fs_1 = require("fs");
|
|
14
|
-
function saveData(filename, newData, uniqueKeys = []) {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
let existingData = [];
|
|
17
|
-
try {
|
|
18
|
-
const data = yield fs_1.promises.readFile(filename, 'utf8');
|
|
19
|
-
existingData = JSON.parse(data);
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
return {
|
|
23
|
-
success: false,
|
|
24
|
-
message: 'Error reading file or file is empty',
|
|
25
|
-
documentsCount: 0,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (uniqueKeys.length > 0) {
|
|
29
|
-
const isUnique = !existingData.some(item => uniqueKeys.every(key => item[key] === newData[key]));
|
|
30
|
-
if (!isUnique) {
|
|
31
|
-
return {
|
|
32
|
-
success: false,
|
|
33
|
-
message: `Data with specified unique keys already exists`,
|
|
34
|
-
insertedData: newData,
|
|
35
|
-
uniqueKeys: uniqueKeys.reduce((obj, key) => {
|
|
36
|
-
obj[key] = newData[key];
|
|
37
|
-
return obj;
|
|
38
|
-
}, {}),
|
|
39
|
-
documentsCount: existingData.length,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
const uniqueProperties = {};
|
|
43
|
-
uniqueKeys.forEach(key => {
|
|
44
|
-
uniqueProperties[key] = newData[key];
|
|
45
|
-
});
|
|
46
|
-
newData['unique'] = uniqueProperties;
|
|
47
|
-
}
|
|
48
|
-
existingData.push(newData);
|
|
49
|
-
try {
|
|
50
|
-
yield fs_1.promises.writeFile(filename, JSON.stringify(existingData, null, 2), 'utf8');
|
|
51
|
-
return {
|
|
52
|
-
success: true,
|
|
53
|
-
message: 'Data saved successfully',
|
|
54
|
-
documentsCount: existingData.length,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
return {
|
|
59
|
-
success: false,
|
|
60
|
-
message: 'Error saving data',
|
|
61
|
-
errorMessage: error.message,
|
|
62
|
-
documentsCount: 0,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
exports.saveData = saveData;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.updateOption = void 0;
|
|
13
|
-
function updateOption(document, updateOptions) {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
for (const key in updateOptions) {
|
|
16
|
-
if (updateOptions.hasOwnProperty(key)) {
|
|
17
|
-
document[key] = updateOptions[key];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return document;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
exports.updateOption = updateOption;
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var userTemplate = {
|
|
4
|
-
userName: null,
|
|
5
|
-
userId: null,
|
|
6
|
-
age: null,
|
|
7
|
-
balance: null,
|
|
8
|
-
password: null,
|
|
9
|
-
};
|
|
10
|
-
var guildInfo = {
|
|
11
|
-
serverId: null,
|
|
12
|
-
serverName: null,
|
|
13
|
-
serverAge: null,
|
|
14
|
-
ownerId: null,
|
|
15
|
-
ownerName: null,
|
|
16
|
-
serverPrefix: null,
|
|
17
|
-
boostCount: null,
|
|
18
|
-
serverDescription: null,
|
|
19
|
-
memberCount: null,
|
|
20
|
-
botsCount: null,
|
|
21
|
-
totalMembers: null,
|
|
22
|
-
channelCount: null,
|
|
23
|
-
roleCount: null,
|
|
24
|
-
emojiCount: null,
|
|
25
|
-
};
|
|
26
|
-
var xpCount = {
|
|
27
|
-
xp: null,
|
|
28
|
-
level: null,
|
|
29
|
-
rank: null,
|
|
30
|
-
userId: null,
|
|
31
|
-
severId: null,
|
|
32
|
-
voiceXp: null,
|
|
33
|
-
voiceLevel: null,
|
|
34
|
-
};
|
|
35
|
-
var xpConfig = {
|
|
36
|
-
xpCount: null,
|
|
37
|
-
xpVoiceCount: null,
|
|
38
|
-
serverId: null,
|
|
39
|
-
channelId: null,
|
|
40
|
-
xpMessage: null,
|
|
41
|
-
xpVoiceMessage: null,
|
|
42
|
-
status: null,
|
|
43
|
-
xpVoiceStatus: null
|
|
44
|
-
};
|
|
45
|
-
var userEco = {
|
|
46
|
-
userId: null,
|
|
47
|
-
serverId: null,
|
|
48
|
-
wallet: null,
|
|
49
|
-
bank: null,
|
|
50
|
-
level: null,
|
|
51
|
-
rank: null,
|
|
52
|
-
inventory: null,
|
|
53
|
-
lastDaily: null,
|
|
54
|
-
dailyStreak: null,
|
|
55
|
-
job: null,
|
|
56
|
-
companies: null,
|
|
57
|
-
lastClaim: null,
|
|
58
|
-
lastRob: null,
|
|
59
|
-
};
|
|
60
|
-
var productInfo = {
|
|
61
|
-
productId: null,
|
|
62
|
-
productName: null,
|
|
63
|
-
category: null,
|
|
64
|
-
price: null,
|
|
65
|
-
stock: null,
|
|
66
|
-
manufacturer: null,
|
|
67
|
-
};
|
|
68
|
-
var blogPost = {
|
|
69
|
-
postId: null,
|
|
70
|
-
title: null,
|
|
71
|
-
content: null,
|
|
72
|
-
authorId: null,
|
|
73
|
-
publishDate: null,
|
|
74
|
-
tags: null,
|
|
75
|
-
};
|
|
76
|
-
var eventInfo = {
|
|
77
|
-
eventId: null,
|
|
78
|
-
eventName: null,
|
|
79
|
-
location: null,
|
|
80
|
-
startDate: null,
|
|
81
|
-
endDate: null,
|
|
82
|
-
organizer: null,
|
|
83
|
-
participants: null,
|
|
84
|
-
};
|
|
85
|
-
var contactInfo = {
|
|
86
|
-
contactId: null,
|
|
87
|
-
firstName: null,
|
|
88
|
-
lastName: null,
|
|
89
|
-
email: null,
|
|
90
|
-
phone: null,
|
|
91
|
-
address: null,
|
|
92
|
-
};
|
|
93
|
-
var shopItem = {
|
|
94
|
-
price: null,
|
|
95
|
-
name: null,
|
|
96
|
-
emoji: null,
|
|
97
|
-
description: null,
|
|
98
|
-
vip: null,
|
|
99
|
-
stock: null,
|
|
100
|
-
sold: null,
|
|
101
|
-
category: null,
|
|
102
|
-
type: null,
|
|
103
|
-
role: null,
|
|
104
|
-
};
|
|
105
|
-
var roleMenu = {
|
|
106
|
-
roleId: null,
|
|
107
|
-
roleName: null,
|
|
108
|
-
roleEmoji: null,
|
|
109
|
-
roleDescription: null,
|
|
110
|
-
roleCategory: null,
|
|
111
|
-
serverId: null,
|
|
112
|
-
};
|
|
113
|
-
var ecoSystem = {
|
|
114
|
-
serverId: null,
|
|
115
|
-
status: null,
|
|
116
|
-
levelUpMessage: null,
|
|
117
|
-
channelId: null,
|
|
118
|
-
};
|
|
119
|
-
var adminUser = {
|
|
120
|
-
userId: null,
|
|
121
|
-
serverId: null,
|
|
122
|
-
roleId: null,
|
|
123
|
-
permission: null,
|
|
124
|
-
adminPerms: null,
|
|
125
|
-
};
|
|
126
|
-
var blackList = {
|
|
127
|
-
userId: null,
|
|
128
|
-
serverId: null,
|
|
129
|
-
reason: null,
|
|
130
|
-
blacklistTime: null,
|
|
131
|
-
};
|
|
132
|
-
var whiteList = {
|
|
133
|
-
userId: null,
|
|
134
|
-
serverId: null,
|
|
135
|
-
};
|
|
136
|
-
var cooldDown = {
|
|
137
|
-
userId: null,
|
|
138
|
-
time: null,
|
|
139
|
-
command: null,
|
|
140
|
-
serverId: null,
|
|
141
|
-
};
|
|
142
|
-
var productReview = {
|
|
143
|
-
reviewId: null,
|
|
144
|
-
productId: null,
|
|
145
|
-
userId: null,
|
|
146
|
-
rating: null,
|
|
147
|
-
comment: null,
|
|
148
|
-
reviewDate: null,
|
|
149
|
-
};
|
|
150
|
-
var orderInfo = {
|
|
151
|
-
orderId: null,
|
|
152
|
-
userId: null,
|
|
153
|
-
products: null,
|
|
154
|
-
orderDate: null,
|
|
155
|
-
totalAmount: null,
|
|
156
|
-
paymentStatus: null,
|
|
157
|
-
};
|
|
158
|
-
var forumPost = {
|
|
159
|
-
postId: null,
|
|
160
|
-
title: null,
|
|
161
|
-
content: null,
|
|
162
|
-
authorId: null,
|
|
163
|
-
postDate: null,
|
|
164
|
-
upvotes: null,
|
|
165
|
-
downvotes: null,
|
|
166
|
-
};
|
|
167
|
-
var recipeInfo = {
|
|
168
|
-
recipeId: null,
|
|
169
|
-
title: null,
|
|
170
|
-
ingredients: null,
|
|
171
|
-
instructions: null,
|
|
172
|
-
authorId: null,
|
|
173
|
-
publishDate: null,
|
|
174
|
-
category: null,
|
|
175
|
-
};
|
|
176
|
-
var musicTrack = {
|
|
177
|
-
trackId: null,
|
|
178
|
-
title: null,
|
|
179
|
-
artist: null,
|
|
180
|
-
album: null,
|
|
181
|
-
genre: null,
|
|
182
|
-
releaseDate: null,
|
|
183
|
-
playCount: null,
|
|
184
|
-
duration: null,
|
|
185
|
-
};
|
|
186
|
-
var employeeInfo = {
|
|
187
|
-
employeeId: null,
|
|
188
|
-
firstName: null,
|
|
189
|
-
lastName: null,
|
|
190
|
-
position: null,
|
|
191
|
-
department: null,
|
|
192
|
-
hireDate: null,
|
|
193
|
-
salary: null,
|
|
194
|
-
};
|
|
195
|
-
var gameCount = {
|
|
196
|
-
serverId: null,
|
|
197
|
-
lastNumber: null,
|
|
198
|
-
channelId: null,
|
|
199
|
-
};
|
|
200
|
-
var setGameCount = {
|
|
201
|
-
serverId: null,
|
|
202
|
-
channelId: null,
|
|
203
|
-
status: null,
|
|
204
|
-
};
|
|
205
|
-
var setserverCounter = {
|
|
206
|
-
serverId: null,
|
|
207
|
-
memberCountChannelId: null,
|
|
208
|
-
emojisCountChannelId: null,
|
|
209
|
-
botsCountChannelId: null,
|
|
210
|
-
channelsCountChannelId: null,
|
|
211
|
-
rolesCountChannelId: null,
|
|
212
|
-
boostCountChannelId: null,
|
|
213
|
-
serverURLChannelId: null,
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
exports.userTemplate = exports.guildInfo = exports.setserverCounter = exports.employeeInfo = exports.gameCount = exports.setGameCount
|
|
217
|
-
= exports.musicTrack = exports.recipeInfo = exports.productReview = exports.orderInfo = exports.forumPost = exports.xpCount = exports.xpConfig
|
|
218
|
-
= exports.userEco = exports.productInfo = exports.blogPost = exports.eventInfo = exports.shopItem = exports.contactInfo = exports.roleMenu
|
|
219
|
-
= exports.ecoSystem = exports.adminUser = exports.blackList = exports.whiteList = exports.cooldDown = void 0;
|
|
220
|
-
|
|
221
|
-
Object.defineProperty(exports, "userTemplate", { enumerable: true, get: function () { return userTemplate; } });
|
|
222
|
-
Object.defineProperty(exports, "guildInfo", { enumerable: true, get: function () { return guildInfo; } });
|
|
223
|
-
Object.defineProperty(exports, "setserverCounter", { enumerable: true, get: function () { return setserverCounter; } });
|
|
224
|
-
Object.defineProperty(exports, "employeeInfo", { enumerable: true, get: function () { return employeeInfo; } });
|
|
225
|
-
Object.defineProperty(exports, "gameCount", { enumerable: true, get: function () { return gameCount; } });
|
|
226
|
-
Object.defineProperty(exports, "setGameCount", { enumerable: true, get: function () { return setGameCount; } });
|
|
227
|
-
Object.defineProperty(exports, "musicTrack", { enumerable: true, get: function () { return musicTrack; } });
|
|
228
|
-
Object.defineProperty(exports, "recipeInfo", { enumerable: true, get: function () { return recipeInfo; } });
|
|
229
|
-
Object.defineProperty(exports, "productReview", { enumerable: true, get: function () { return productReview; } });
|
|
230
|
-
Object.defineProperty(exports, "orderInfo", { enumerable: true, get: function () { return orderInfo; } });
|
|
231
|
-
Object.defineProperty(exports, "forumPost", { enumerable: true, get: function () { return forumPost; } });
|
|
232
|
-
Object.defineProperty(exports, "xpCount", { enumerable: true, get: function () { return xpCount; } });
|
|
233
|
-
Object.defineProperty(exports, "xpConfig", { enumerable: true, get: function () { return xpConfig; } });
|
|
234
|
-
Object.defineProperty(exports, "userEco", { enumerable: true, get: function () { return userEco; } });
|
|
235
|
-
Object.defineProperty(exports, "productInfo", { enumerable: true, get: function () { return productInfo; } });
|
|
236
|
-
Object.defineProperty(exports, "blogPost", { enumerable: true, get: function () { return blogPost; } });
|
|
237
|
-
Object.defineProperty(exports, "eventInfo", { enumerable: true, get: function () { return eventInfo; } });
|
|
238
|
-
Object.defineProperty(exports, "shopItem", { enumerable: true, get: function () { return shopItem; } });
|
|
239
|
-
Object.defineProperty(exports, "contactInfo", { enumerable: true, get: function () { return contactInfo; } });
|
|
240
|
-
Object.defineProperty(exports, "roleMenu", { enumerable: true, get: function () { return roleMenu; } });
|
|
241
|
-
Object.defineProperty(exports, "ecoSystem", { enumerable: true, get: function () { return ecoSystem; } });
|
|
242
|
-
Object.defineProperty(exports, "adminUser", { enumerable: true, get: function () { return adminUser; } });
|
|
243
|
-
Object.defineProperty(exports, "blackList", { enumerable: true, get: function () { return blackList; } });
|
|
244
|
-
Object.defineProperty(exports, "whiteList", { enumerable: true, get: function () { return whiteList; } });
|
|
245
|
-
Object.defineProperty(exports, "cooldDown", { enumerable: true, get: function () { return cooldDown; } });
|