@elara-services/packages 5.3.1 → 6.0.1

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.
Files changed (69) hide show
  1. package/dist/package.json +44 -0
  2. package/dist/src/index.d.ts +1 -0
  3. package/dist/src/index.js +17 -0
  4. package/dist/src/interfaces/discord.d.ts +91 -0
  5. package/dist/src/interfaces/discord.js +2 -0
  6. package/dist/src/interfaces/index.d.ts +1 -0
  7. package/dist/src/interfaces/index.js +17 -0
  8. package/dist/src/lib/AES.d.ts +7 -0
  9. package/dist/src/lib/AES.js +82 -0
  10. package/dist/src/lib/discord.d.ts +136 -0
  11. package/dist/src/lib/discord.js +381 -0
  12. package/dist/src/lib/index.d.ts +8 -0
  13. package/dist/src/lib/index.js +24 -0
  14. package/dist/src/lib/languages.d.ts +220 -0
  15. package/dist/src/lib/languages.js +125 -0
  16. package/dist/src/lib/minesweeper.d.ts +20 -0
  17. package/dist/src/lib/minesweeper.js +81 -0
  18. package/dist/src/lib/misc.d.ts +1 -0
  19. package/dist/src/lib/misc.js +73 -0
  20. package/dist/src/lib/random.d.ts +16 -0
  21. package/dist/src/lib/random.js +2035 -0
  22. package/dist/src/lib/tasks.d.ts +9 -0
  23. package/dist/src/lib/tasks.js +72 -0
  24. package/docs/.nojekyll +1 -0
  25. package/docs/assets/highlight.css +22 -0
  26. package/docs/assets/main.js +58 -0
  27. package/docs/assets/search.js +1 -0
  28. package/docs/assets/style.css +1367 -0
  29. package/docs/classes/AES.html +144 -0
  30. package/docs/classes/Minesweeper.html +205 -0
  31. package/docs/classes/Tasks.html +141 -0
  32. package/docs/functions/fetch.html +89 -0
  33. package/docs/functions/randomWeight.html +79 -0
  34. package/docs/functions/randomWords.html +74 -0
  35. package/docs/index.html +163 -0
  36. package/docs/interfaces/ButtonOptions.html +154 -0
  37. package/docs/interfaces/ModalOptions.html +124 -0
  38. package/docs/interfaces/RandomWord.html +153 -0
  39. package/docs/interfaces/SelectOptions.html +159 -0
  40. package/docs/interfaces/Slash.html +138 -0
  41. package/docs/interfaces/SlashOptions.html +187 -0
  42. package/docs/interfaces/TaskCreate.html +103 -0
  43. package/docs/interfaces/TextInputOptions.html +180 -0
  44. package/docs/modules.html +101 -0
  45. package/docs/types/ButtonNumberStyles.html +65 -0
  46. package/docs/types/ButtonStyles.html +65 -0
  47. package/docs/types/ChannelTypes.html +65 -0
  48. package/docs/types/Lang.html +65 -0
  49. package/docs/types/LangName.html +65 -0
  50. package/docs/variables/ButtonStyle.html +88 -0
  51. package/docs/variables/Duration.html +109 -0
  52. package/docs/variables/Interactions.html +159 -0
  53. package/docs/variables/Languages.html +294 -0
  54. package/docs/variables/SlashBuilder.html +238 -0
  55. package/package.json +44 -10
  56. package/.github/renovate.json +0 -5
  57. package/CHANGELOG +0 -62
  58. package/index.d.ts +0 -247
  59. package/index.js +0 -11
  60. package/packages/Interactions.js +0 -76
  61. package/packages/SlashBuilder.js +0 -58
  62. package/packages/Tasks.js +0 -22
  63. package/packages/aes256.js +0 -62
  64. package/packages/duration.js +0 -74
  65. package/packages/fetch.js +0 -30
  66. package/packages/languages.js +0 -119
  67. package/packages/minesweeper.js +0 -77
  68. package/packages/random/weight.js +0 -8
  69. package/packages/random/words.js +0 -300
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Languages = void 0;
4
+ const utils_1 = require("@elara-services/utils");
5
+ const 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
+ exports.Languages = {
113
+ langs,
114
+ find(name) {
115
+ for (const key of (0, utils_1.getKeys)(langs)) {
116
+ if (key === name) {
117
+ return key;
118
+ }
119
+ if (langs[key] === name) {
120
+ return key;
121
+ }
122
+ }
123
+ return null;
124
+ },
125
+ };
@@ -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
+ }
@@ -0,0 +1,81 @@
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",
15
+ "one",
16
+ "two",
17
+ "three",
18
+ "four",
19
+ "five",
20
+ "six",
21
+ "seven",
22
+ "eight",
23
+ ],
24
+ };
25
+ }
26
+ generateEmptyMatrix() {
27
+ for (let i = 0; i < this.rows; i++) {
28
+ const arr = new Array(this.columns).fill(this.types.numbers[0]);
29
+ this.matrix.push(arr);
30
+ }
31
+ }
32
+ plantMines() {
33
+ for (let i = 0; i < this.mines; i++) {
34
+ const x = Math.floor(Math.random() * this.rows);
35
+ const y = Math.floor(Math.random() * this.columns);
36
+ if (this.matrix[x][y] === this.types.mine) {
37
+ i--;
38
+ }
39
+ else {
40
+ this.matrix[x][y] = this.types.mine;
41
+ }
42
+ }
43
+ }
44
+ getNumberOfMines(x, y) {
45
+ if (this.matrix[x][y] === this.types.mine) {
46
+ return this.types.mine;
47
+ }
48
+ let counter = 0;
49
+ const hasLeft = y > 0;
50
+ const hasRight = y < this.columns - 1;
51
+ const hasTop = x > 0;
52
+ const hasBottom = x < this.rows - 1;
53
+ counter += +(hasTop &&
54
+ hasLeft &&
55
+ this.matrix[x - 1][y - 1] === this.types.mine);
56
+ counter += +(hasTop && this.matrix[x - 1][y] === this.types.mine);
57
+ counter += +(hasTop &&
58
+ hasRight &&
59
+ this.matrix[x - 1][y + 1] === this.types.mine);
60
+ counter += +(hasLeft && this.matrix[x][y - 1] === this.types.mine);
61
+ counter += +(hasRight && this.matrix[x][y + 1] === this.types.mine);
62
+ counter += +(hasBottom &&
63
+ hasLeft &&
64
+ this.matrix[x + 1][y - 1] === this.types.mine);
65
+ counter += +(hasBottom && this.matrix[x + 1][y] === this.types.mine);
66
+ counter += +(hasBottom &&
67
+ hasRight &&
68
+ this.matrix[x + 1][y + 1] === this.types.mine);
69
+ return this.types.numbers[counter];
70
+ }
71
+ start() {
72
+ if (this.rows * this.columns <= this.mines * 2) {
73
+ return null;
74
+ }
75
+ this.generateEmptyMatrix();
76
+ this.plantMines();
77
+ this.matrix = this.matrix.map((row, x) => row.map((col, y) => this.getNumberOfMines(x, y)));
78
+ return this.matrix;
79
+ }
80
+ }
81
+ 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,73 @@
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
55
+ .fetch(url, postRequest ? "POST" : "GET")
56
+ .header(headers)
57
+ .body(body, "json")
58
+ .send()
59
+ .catch(() => ({ statusCode: 500, body: "", json: () => "" }));
60
+ if (res.statusCode !== 200) {
61
+ return null;
62
+ }
63
+ if (returnRaw) {
64
+ return res.body;
65
+ }
66
+ return res.json();
67
+ }
68
+ catch (_a) {
69
+ return null;
70
+ }
71
+ });
72
+ }
73
+ 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[];