@elara-services/packages 5.3.1 → 6.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/dist/package.json +44 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +17 -0
- package/dist/src/interfaces/discord.d.ts +91 -0
- package/dist/src/interfaces/discord.js +2 -0
- package/dist/src/interfaces/index.d.ts +1 -0
- package/dist/src/interfaces/index.js +17 -0
- package/dist/src/lib/AES.d.ts +7 -0
- package/dist/src/lib/AES.js +71 -0
- package/dist/src/lib/discord.d.ts +136 -0
- package/dist/src/lib/discord.js +336 -0
- package/dist/src/lib/index.d.ts +8 -0
- package/dist/src/lib/index.js +24 -0
- package/dist/src/lib/languages.d.ts +110 -0
- package/{packages → dist/src/lib}/languages.js +123 -119
- package/dist/src/lib/minesweeper.d.ts +20 -0
- package/{packages → dist/src/lib}/minesweeper.js +67 -77
- package/dist/src/lib/misc.d.ts +1 -0
- package/dist/src/lib/misc.js +72 -0
- package/dist/src/lib/random.d.ts +16 -0
- package/dist/src/lib/random.js +326 -0
- package/dist/src/lib/tasks.d.ts +9 -0
- package/dist/src/lib/tasks.js +68 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +22 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1367 -0
- package/docs/classes/AES.html +145 -0
- package/docs/classes/Minesweeper.html +206 -0
- package/docs/classes/Tasks.html +142 -0
- package/docs/functions/fetch.html +90 -0
- package/docs/functions/find.html +75 -0
- package/docs/functions/randomWeight.html +80 -0
- package/docs/functions/randomWords.html +75 -0
- package/docs/index.html +164 -0
- package/docs/interfaces/ButtonOptions.html +155 -0
- package/docs/interfaces/ModalOptions.html +125 -0
- package/docs/interfaces/RandomWord.html +154 -0
- package/docs/interfaces/SelectOptions.html +160 -0
- package/docs/interfaces/Slash.html +139 -0
- package/docs/interfaces/SlashOptions.html +188 -0
- package/docs/interfaces/TaskCreate.html +104 -0
- package/docs/interfaces/TextInputOptions.html +181 -0
- package/docs/modules.html +103 -0
- package/docs/types/ButtonNumberStyles.html +66 -0
- package/docs/types/ButtonStyles.html +66 -0
- package/docs/types/ChannelTypes.html +66 -0
- package/docs/types/Lang.html +66 -0
- package/docs/types/LangName.html +66 -0
- package/docs/variables/ButtonStyle.html +89 -0
- package/docs/variables/Duration.html +110 -0
- package/docs/variables/Interactions.html +160 -0
- package/docs/variables/SlashBuilder.html +239 -0
- package/docs/variables/langs.html +279 -0
- package/package.json +44 -10
- package/.github/renovate.json +0 -5
- package/CHANGELOG +0 -62
- package/index.d.ts +0 -247
- package/index.js +0 -11
- package/packages/Interactions.js +0 -76
- package/packages/SlashBuilder.js +0 -58
- package/packages/Tasks.js +0 -22
- package/packages/aes256.js +0 -62
- package/packages/duration.js +0 -74
- package/packages/fetch.js +0 -30
- package/packages/random/weight.js +0 -8
- package/packages/random/words.js +0 -300
@@ -1,119 +1,123 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
'
|
7
|
-
'
|
8
|
-
'
|
9
|
-
|
10
|
-
'
|
11
|
-
'
|
12
|
-
'
|
13
|
-
'
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'
|
24
|
-
'
|
25
|
-
'
|
26
|
-
'
|
27
|
-
'
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
31
|
-
'
|
32
|
-
'
|
33
|
-
'
|
34
|
-
'
|
35
|
-
'
|
36
|
-
'
|
37
|
-
'
|
38
|
-
'
|
39
|
-
'
|
40
|
-
'
|
41
|
-
'
|
42
|
-
'
|
43
|
-
'
|
44
|
-
'
|
45
|
-
'
|
46
|
-
'
|
47
|
-
'
|
48
|
-
'
|
49
|
-
'
|
50
|
-
'
|
51
|
-
'
|
52
|
-
'
|
53
|
-
'
|
54
|
-
'
|
55
|
-
'
|
56
|
-
'
|
57
|
-
'
|
58
|
-
'
|
59
|
-
'
|
60
|
-
'
|
61
|
-
'
|
62
|
-
'
|
63
|
-
'
|
64
|
-
'
|
65
|
-
'
|
66
|
-
'
|
67
|
-
'
|
68
|
-
'
|
69
|
-
'
|
70
|
-
'
|
71
|
-
'
|
72
|
-
'
|
73
|
-
'
|
74
|
-
'
|
75
|
-
'
|
76
|
-
'
|
77
|
-
'
|
78
|
-
'
|
79
|
-
'
|
80
|
-
'
|
81
|
-
'
|
82
|
-
'
|
83
|
-
'
|
84
|
-
'
|
85
|
-
'
|
86
|
-
'
|
87
|
-
'
|
88
|
-
'
|
89
|
-
'
|
90
|
-
'
|
91
|
-
'
|
92
|
-
'
|
93
|
-
'
|
94
|
-
'
|
95
|
-
'
|
96
|
-
'
|
97
|
-
'
|
98
|
-
'
|
99
|
-
'
|
100
|
-
'
|
101
|
-
'
|
102
|
-
'
|
103
|
-
'
|
104
|
-
'
|
105
|
-
'
|
106
|
-
'
|
107
|
-
'
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
}
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.find = exports.langs = void 0;
|
4
|
+
const utils_1 = require("@elara-services/utils");
|
5
|
+
exports.langs = {
|
6
|
+
'en': 'English',
|
7
|
+
'fr': 'French',
|
8
|
+
'es': 'Spanish',
|
9
|
+
'pt': 'Portuguese',
|
10
|
+
'tr': 'Turkish',
|
11
|
+
'ru': 'Russian',
|
12
|
+
'ar': 'Arabic',
|
13
|
+
'af': 'Afrikaans',
|
14
|
+
'sq': 'Albanian',
|
15
|
+
'am': 'Amharic',
|
16
|
+
'hy': 'Armenian',
|
17
|
+
'az': 'Azerbaijani',
|
18
|
+
'eu': 'Basque',
|
19
|
+
'be': 'Belarusian',
|
20
|
+
'bn': 'Bengali',
|
21
|
+
'bs': 'Bosnian',
|
22
|
+
'bg': 'Bulgarian',
|
23
|
+
'ca': 'Catalan',
|
24
|
+
'ceb': 'Cebuano',
|
25
|
+
'ny': 'Chichewa',
|
26
|
+
'zh': 'Chinese (Simplified)',
|
27
|
+
'zh-tw': 'Chinese (Traditional)',
|
28
|
+
'co': 'Corsican',
|
29
|
+
'hr': 'Croatian',
|
30
|
+
'cs': 'Czech',
|
31
|
+
'da': 'Danish',
|
32
|
+
'nl': 'Dutch',
|
33
|
+
'eo': 'Esperanto',
|
34
|
+
'et': 'Estonian',
|
35
|
+
'tl': 'Filipino',
|
36
|
+
'fi': 'Finnish',
|
37
|
+
'fy': 'Frisian',
|
38
|
+
'gl': 'Galician',
|
39
|
+
'ka': 'Georgian',
|
40
|
+
'de': 'German',
|
41
|
+
'el': 'Greek',
|
42
|
+
'gu': 'Gujarati',
|
43
|
+
'ht': 'Haitian Creole',
|
44
|
+
'ha': 'Hausa',
|
45
|
+
'haw': 'Hawaiian',
|
46
|
+
'he': 'Hebrew',
|
47
|
+
'iw': 'Hebrew',
|
48
|
+
'hi': 'Hindi',
|
49
|
+
'hmn': 'Hmong',
|
50
|
+
'hu': 'Hungarian',
|
51
|
+
'is': 'Icelandic',
|
52
|
+
'ig': 'Igbo',
|
53
|
+
'id': 'Indonesian',
|
54
|
+
'ga': 'Irish',
|
55
|
+
'it': 'Italian',
|
56
|
+
'ja': 'Japanese',
|
57
|
+
'jw': 'Javanese',
|
58
|
+
'kn': 'Kannada',
|
59
|
+
'kk': 'Kazakh',
|
60
|
+
'km': 'Khmer',
|
61
|
+
'ko': 'Korean',
|
62
|
+
'ku': 'Kurdish (Kurmanji)',
|
63
|
+
'ky': 'Kyrgyz',
|
64
|
+
'lo': 'Lao',
|
65
|
+
'la': 'Latin',
|
66
|
+
'lv': 'Latvian',
|
67
|
+
'lt': 'Lithuanian',
|
68
|
+
'lb': 'Luxembourgish',
|
69
|
+
'mk': 'Macedonian',
|
70
|
+
'mg': 'Malagasy',
|
71
|
+
'ms': 'Malay',
|
72
|
+
'ml': 'Malayalam',
|
73
|
+
'mt': 'Maltese',
|
74
|
+
'mi': 'Maori',
|
75
|
+
'mr': 'Marathi',
|
76
|
+
'mn': 'Mongolian',
|
77
|
+
'my': 'Myanmar (Burmese)',
|
78
|
+
'ne': 'Nepali',
|
79
|
+
'no': 'Norwegian',
|
80
|
+
'ps': 'Pashto',
|
81
|
+
'fa': 'Persian',
|
82
|
+
'pl': 'Polish',
|
83
|
+
'pa': 'Punjabi',
|
84
|
+
'ro': 'Romanian',
|
85
|
+
'sm': 'Samoan',
|
86
|
+
'gd': 'Scots Gaelic',
|
87
|
+
'sr': 'Serbian',
|
88
|
+
'st': 'Sesotho',
|
89
|
+
'sn': 'Shona',
|
90
|
+
'sd': 'Sindhi',
|
91
|
+
'si': 'Sinhala',
|
92
|
+
'sk': 'Slovak',
|
93
|
+
'sl': 'Slovenian',
|
94
|
+
'so': 'Somali',
|
95
|
+
'su': 'Sundanese',
|
96
|
+
'sw': 'Swahili',
|
97
|
+
'sv': 'Swedish',
|
98
|
+
'tg': 'Tajik',
|
99
|
+
'ta': 'Tamil',
|
100
|
+
'te': 'Telugu',
|
101
|
+
'th': 'Thai',
|
102
|
+
'uk': 'Ukrainian',
|
103
|
+
'ur': 'Urdu',
|
104
|
+
'uz': 'Uzbek',
|
105
|
+
'vi': 'Vietnamese',
|
106
|
+
'cy': 'Welsh',
|
107
|
+
'xh': 'Xhosa',
|
108
|
+
'yi': 'Yiddish',
|
109
|
+
'yo': 'Yoruba',
|
110
|
+
'zu': 'Zulu'
|
111
|
+
};
|
112
|
+
function find(name) {
|
113
|
+
for (const key of (0, utils_1.getKeys)(exports.langs)) {
|
114
|
+
if (key === name) {
|
115
|
+
return key;
|
116
|
+
}
|
117
|
+
if (exports.langs[key] === name) {
|
118
|
+
return key;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
return null;
|
122
|
+
}
|
123
|
+
exports.find = find;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
export declare class Minesweeper {
|
2
|
+
rows: number;
|
3
|
+
columns: number;
|
4
|
+
mines: number;
|
5
|
+
matrix: string[][];
|
6
|
+
types: {
|
7
|
+
mine: string;
|
8
|
+
numbers: string[];
|
9
|
+
};
|
10
|
+
constructor(opts: {
|
11
|
+
rows?: number;
|
12
|
+
columns?: number;
|
13
|
+
mines?: number;
|
14
|
+
emote?: string;
|
15
|
+
});
|
16
|
+
generateEmptyMatrix(): void;
|
17
|
+
plantMines(): void;
|
18
|
+
getNumberOfMines(x: number, y: number): string;
|
19
|
+
start(): string[][] | null;
|
20
|
+
}
|
@@ -1,77 +1,67 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
this.
|
9
|
-
this.
|
10
|
-
this.
|
11
|
-
this.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
'
|
16
|
-
'
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
return this.
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
* Generates a minesweeper mine field and returns it.
|
69
|
-
* @returns {(string | string[][] | null)}
|
70
|
-
*/
|
71
|
-
start() {
|
72
|
-
if (this.rows * this.columns <= this.mines * 2) return null;
|
73
|
-
for (const n of [ "generateEmptyMatrix", "plantMines" ]) this[n]();
|
74
|
-
this.matrix = this.matrix.map((row, x) => row.map((col, y) => this.getNumberOfMines(x, y)));
|
75
|
-
return this.matrix;
|
76
|
-
}
|
77
|
-
};
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Minesweeper = void 0;
|
4
|
+
class Minesweeper {
|
5
|
+
constructor(opts) {
|
6
|
+
var _a, _b, _c, _d;
|
7
|
+
this.rows = (_a = opts === null || opts === void 0 ? void 0 : opts.rows) !== null && _a !== void 0 ? _a : 5;
|
8
|
+
this.columns = (_b = opts === null || opts === void 0 ? void 0 : opts.columns) !== null && _b !== void 0 ? _b : 5;
|
9
|
+
this.mines = (_c = opts === null || opts === void 0 ? void 0 : opts.mines) !== null && _c !== void 0 ? _c : 5;
|
10
|
+
this.matrix = [];
|
11
|
+
this.types = {
|
12
|
+
mine: (_d = opts === null || opts === void 0 ? void 0 : opts.emote) !== null && _d !== void 0 ? _d : "bomb",
|
13
|
+
numbers: [
|
14
|
+
'zero', 'one', 'two',
|
15
|
+
'three', 'four', 'five',
|
16
|
+
'six', 'seven', 'eight'
|
17
|
+
]
|
18
|
+
};
|
19
|
+
}
|
20
|
+
generateEmptyMatrix() {
|
21
|
+
for (let i = 0; i < this.rows; i++) {
|
22
|
+
const arr = new Array(this.columns).fill(this.types.numbers[0]);
|
23
|
+
this.matrix.push(arr);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
plantMines() {
|
27
|
+
for (let i = 0; i < this.mines; i++) {
|
28
|
+
const x = Math.floor(Math.random() * this.rows);
|
29
|
+
const y = Math.floor(Math.random() * this.columns);
|
30
|
+
if (this.matrix[x][y] === this.types.mine) {
|
31
|
+
i--;
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
this.matrix[x][y] = this.types.mine;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
getNumberOfMines(x, y) {
|
39
|
+
if (this.matrix[x][y] === this.types.mine) {
|
40
|
+
return this.types.mine;
|
41
|
+
}
|
42
|
+
let counter = 0;
|
43
|
+
const hasLeft = y > 0;
|
44
|
+
const hasRight = y < (this.columns - 1);
|
45
|
+
const hasTop = x > 0;
|
46
|
+
const hasBottom = x < (this.rows - 1);
|
47
|
+
counter += +(hasTop && hasLeft && this.matrix[x - 1][y - 1] === this.types.mine);
|
48
|
+
counter += +(hasTop && this.matrix[x - 1][y] === this.types.mine);
|
49
|
+
counter += +(hasTop && hasRight && this.matrix[x - 1][y + 1] === this.types.mine);
|
50
|
+
counter += +(hasLeft && this.matrix[x][y - 1] === this.types.mine);
|
51
|
+
counter += +(hasRight && this.matrix[x][y + 1] === this.types.mine);
|
52
|
+
counter += +(hasBottom && hasLeft && this.matrix[x + 1][y - 1] === this.types.mine);
|
53
|
+
counter += +(hasBottom && this.matrix[x + 1][y] === this.types.mine);
|
54
|
+
counter += +(hasBottom && hasRight && this.matrix[x + 1][y + 1] === this.types.mine);
|
55
|
+
return this.types.numbers[counter];
|
56
|
+
}
|
57
|
+
start() {
|
58
|
+
if (this.rows * this.columns <= this.mines * 2) {
|
59
|
+
return null;
|
60
|
+
}
|
61
|
+
this.generateEmptyMatrix();
|
62
|
+
this.plantMines();
|
63
|
+
this.matrix = this.matrix.map((row, x) => row.map((col, y) => this.getNumberOfMines(x, y)));
|
64
|
+
return this.matrix;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
exports.Minesweeper = Minesweeper;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function fetch<B extends object, T>(url: string, key?: string, body?: B | undefined, postRequest?: boolean, returnRaw?: boolean): Promise<T | null>;
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
|
+
});
|
33
|
+
};
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
35
|
+
exports.fetch = void 0;
|
36
|
+
function fetch(url, key = "", body = undefined, postRequest = false, returnRaw = false) {
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
38
|
+
try {
|
39
|
+
const client = yield Promise.resolve().then(() => __importStar(require("@elara-services/fetch"))).catch(() => { });
|
40
|
+
if (!client) {
|
41
|
+
throw new Error(`NPM package (@elara-services/fetch) now found`);
|
42
|
+
}
|
43
|
+
const headers = {
|
44
|
+
"User-Agent": `Services v${Math.floor(Math.random() * 999999)}`,
|
45
|
+
authorization: ""
|
46
|
+
};
|
47
|
+
if (key !== "" && key) {
|
48
|
+
headers['authorization'] = key;
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
// @ts-expect-error
|
52
|
+
delete headers['authorization'];
|
53
|
+
}
|
54
|
+
const res = yield client.fetch(url, postRequest ? "POST" : "GET")
|
55
|
+
.header(headers)
|
56
|
+
.body(body, "json")
|
57
|
+
.send()
|
58
|
+
.catch(() => ({ statusCode: 500, body: "", json: () => "" }));
|
59
|
+
if (res.statusCode !== 200) {
|
60
|
+
return null;
|
61
|
+
}
|
62
|
+
if (returnRaw) {
|
63
|
+
return res.body;
|
64
|
+
}
|
65
|
+
return res.json();
|
66
|
+
}
|
67
|
+
catch (_a) {
|
68
|
+
return null;
|
69
|
+
}
|
70
|
+
});
|
71
|
+
}
|
72
|
+
exports.fetch = fetch;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
export declare function randomWeight<T>(objects: (T & {
|
2
|
+
weight: number;
|
3
|
+
})[]): (T & {
|
4
|
+
weight: number;
|
5
|
+
}) | undefined;
|
6
|
+
export interface RandomWord {
|
7
|
+
exactly?: boolean;
|
8
|
+
maxLength?: number;
|
9
|
+
min?: number;
|
10
|
+
max?: number;
|
11
|
+
wordsPerString?: number;
|
12
|
+
formatter(word: string | undefined, relativeIndex?: number): void;
|
13
|
+
separator: string;
|
14
|
+
join: string;
|
15
|
+
}
|
16
|
+
export declare function randomWords(options: RandomWord): string | string[];
|