@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
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"name": "@elara-services/packages",
|
3
|
+
"version": "6.0.0",
|
4
|
+
"description": "",
|
5
|
+
"main": "./dist/src/index.js",
|
6
|
+
"author": "SUPERCHIEFYT (Elara-Discord-Bots, Elara-Services)",
|
7
|
+
"license": "ISC",
|
8
|
+
"scripts": {
|
9
|
+
"build": "rm -rf dist && rm -rf docs && tsc && npx typedoc src/index.ts",
|
10
|
+
"pub": "npm run build && npm publish",
|
11
|
+
"lint": "eslint .",
|
12
|
+
"prettier:format": "prettier --write src/**/*.ts",
|
13
|
+
"prettier:check": "prettier --check src/**/*.ts"
|
14
|
+
},
|
15
|
+
"repository": {
|
16
|
+
"type": "git",
|
17
|
+
"url": "https://github.com/elara-bots/npm/tree/main/packages"
|
18
|
+
},
|
19
|
+
"files": [
|
20
|
+
"dist",
|
21
|
+
"docs"
|
22
|
+
],
|
23
|
+
"devDependencies": {
|
24
|
+
"@types/node": "20.3.0",
|
25
|
+
"@types/node-schedule": "2.1.0",
|
26
|
+
"@typescript-eslint/eslint-plugin": "5.59.9",
|
27
|
+
"@typescript-eslint/parser": "5.59.9",
|
28
|
+
"dotenv": "16.1.4",
|
29
|
+
"eslint": "8.42.0",
|
30
|
+
"nodemon": "2.0.22",
|
31
|
+
"prettier": "3.0.0",
|
32
|
+
"ts-node": "10.9.1",
|
33
|
+
"typedoc": "0.24.8",
|
34
|
+
"typescript": "5.1.3"
|
35
|
+
},
|
36
|
+
"optionalDependencies": {
|
37
|
+
"@elara-services/fetch": "2.0.1",
|
38
|
+
"node-schedule": "2.1.1"
|
39
|
+
},
|
40
|
+
"dependencies": {
|
41
|
+
"@elara-services/utils": "1.2.14",
|
42
|
+
"discord-api-types": "0.37.48"
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./lib";
|
@@ -0,0 +1,17 @@
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./lib"), exports);
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import { APIModalActionRowComponent, APISelectMenuOption, ComponentType } from "discord-api-types/v10";
|
2
|
+
export type ButtonStyles = 'PRIMARY' | 'BLURPLE' | 'SECONDARY' | 'GREY' | 'SUCCESS' | 'GREEN' | 'DANGER' | 'RED' | 'LINK' | 'URL';
|
3
|
+
export type ButtonNumberStyles = 1 | 2 | 3 | 4 | 5;
|
4
|
+
export interface ButtonOptions {
|
5
|
+
type?: number;
|
6
|
+
style?: ButtonNumberStyles | ButtonStyles;
|
7
|
+
emoji?: {
|
8
|
+
name?: string | null;
|
9
|
+
id?: string | null;
|
10
|
+
animated?: boolean;
|
11
|
+
};
|
12
|
+
disabled?: boolean;
|
13
|
+
id?: string;
|
14
|
+
title?: string;
|
15
|
+
custom_id?: string;
|
16
|
+
label?: string;
|
17
|
+
url?: string;
|
18
|
+
}
|
19
|
+
export interface SelectOptions {
|
20
|
+
id?: string;
|
21
|
+
custom_id?: string;
|
22
|
+
holder?: string;
|
23
|
+
placeholder?: string;
|
24
|
+
min?: number;
|
25
|
+
max?: number;
|
26
|
+
max_values?: number;
|
27
|
+
min_values?: number;
|
28
|
+
type?: ComponentType.ChannelSelect | ComponentType.MentionableSelect | ComponentType.RoleSelect | ComponentType.StringSelect | ComponentType.UserSelect;
|
29
|
+
disabled?: boolean;
|
30
|
+
options?: APISelectMenuOption[];
|
31
|
+
}
|
32
|
+
export interface ModalOptions {
|
33
|
+
title?: string;
|
34
|
+
label?: string;
|
35
|
+
custom_id?: string;
|
36
|
+
id?: string;
|
37
|
+
components: {
|
38
|
+
type: 1 | ComponentType.ActionRow;
|
39
|
+
components: APIModalActionRowComponent[];
|
40
|
+
}[];
|
41
|
+
}
|
42
|
+
export interface TextInputOptions {
|
43
|
+
type?: ComponentType.TextInput | 4;
|
44
|
+
id?: string;
|
45
|
+
custom_id?: string;
|
46
|
+
title?: string;
|
47
|
+
label?: string;
|
48
|
+
style?: 1 | 2;
|
49
|
+
min?: number;
|
50
|
+
max?: number;
|
51
|
+
max_length?: number;
|
52
|
+
min_length?: number;
|
53
|
+
placeholder?: string;
|
54
|
+
holder?: string;
|
55
|
+
required?: boolean;
|
56
|
+
value?: string;
|
57
|
+
}
|
58
|
+
export interface Slash {
|
59
|
+
type?: number;
|
60
|
+
dm_permission?: boolean;
|
61
|
+
dmPermission?: boolean;
|
62
|
+
defaultMemberPermissions?: string;
|
63
|
+
default_member_permissions?: string;
|
64
|
+
options?: unknown[];
|
65
|
+
locale?: {
|
66
|
+
names?: Record<string, string>;
|
67
|
+
descriptions?: Record<string, string>;
|
68
|
+
};
|
69
|
+
}
|
70
|
+
export type ChannelTypes = 'GUILD_TEXT' | 'DM' | 'GUILD_VOICE' | 'GROUP_DM' | 'GUILD_CATEGORY' | 'GUILD_NEWS' | 'GUILD_STORE' | 'GUILD_NEWS_THREAD' | 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 'GUILD_STAGE_VOICE';
|
71
|
+
export interface SlashOptions {
|
72
|
+
type: number;
|
73
|
+
name: string;
|
74
|
+
description: string;
|
75
|
+
required?: boolean;
|
76
|
+
channel_types?: ChannelTypes[];
|
77
|
+
autocomplete?: boolean;
|
78
|
+
min_value?: number;
|
79
|
+
max_value?: number;
|
80
|
+
min_length?: number;
|
81
|
+
max_length?: number;
|
82
|
+
choices?: {
|
83
|
+
name: string;
|
84
|
+
value: string;
|
85
|
+
}[];
|
86
|
+
options?: SlashOptions[];
|
87
|
+
locale?: {
|
88
|
+
names?: Record<string, string>;
|
89
|
+
descriptions?: Record<string, string>;
|
90
|
+
};
|
91
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./discord";
|
@@ -0,0 +1,17 @@
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./discord"), exports);
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.AES = void 0;
|
4
|
+
const utils_1 = require("@elara-services/utils");
|
5
|
+
const crypto_1 = require("crypto");
|
6
|
+
const package_json_1 = require("../../package.json");
|
7
|
+
const header = `[${package_json_1.name}, v${package_json_1.version}]: [AES]`;
|
8
|
+
class AES {
|
9
|
+
constructor(key) {
|
10
|
+
if (!utils_1.is.string(key)) {
|
11
|
+
throw new Error(`${header} You didn't include a key in the constructor.`);
|
12
|
+
}
|
13
|
+
this.key = key;
|
14
|
+
}
|
15
|
+
encrypt(input) {
|
16
|
+
const isString = utils_1.is.string(input);
|
17
|
+
const isBuffer = Buffer.isBuffer(input);
|
18
|
+
if (!(isString || isBuffer) || (isString && !input) || (isBuffer && !Buffer.byteLength(input))) {
|
19
|
+
throw new Error(`${header} Provided invalid 'input', must be a non-empty string or buffer.`);
|
20
|
+
}
|
21
|
+
const sha = (0, crypto_1.createHash)("sha256");
|
22
|
+
sha.update(this.key);
|
23
|
+
const iv = (0, crypto_1.randomBytes)(16);
|
24
|
+
const cipher = (0, crypto_1.createCipheriv)("aes-256-ctr", sha.digest(), iv);
|
25
|
+
let buffer = input;
|
26
|
+
if (isString) {
|
27
|
+
buffer = Buffer.from(input);
|
28
|
+
}
|
29
|
+
const text = cipher.update(buffer);
|
30
|
+
let encrypted = Buffer.concat([iv, text, cipher.final()]);
|
31
|
+
if (isString) {
|
32
|
+
encrypted = encrypted.toString('base64');
|
33
|
+
}
|
34
|
+
return encrypted;
|
35
|
+
}
|
36
|
+
decrypt(encrypted) {
|
37
|
+
const isString = utils_1.is.string(encrypted);
|
38
|
+
const isBuffer = Buffer.isBuffer(encrypted);
|
39
|
+
if (!(isString || isBuffer) || (isString && !encrypted) || (isBuffer && !Buffer.byteLength(encrypted))) {
|
40
|
+
throw new Error(`${header} Provided "encrypted" must be a non-empty string or buffer`);
|
41
|
+
}
|
42
|
+
const sha256 = (0, crypto_1.createHash)('sha256');
|
43
|
+
sha256.update(this.key);
|
44
|
+
let input = encrypted;
|
45
|
+
if (isString) {
|
46
|
+
// @ts-expect-error
|
47
|
+
input = Buffer.from(encrypted, 'base64');
|
48
|
+
if (input.length < 17) {
|
49
|
+
throw new Error(`${header} Provided "encrypted" must decrypt to a non-empty string or buffer`);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
if (Buffer.byteLength(encrypted) < 17) {
|
54
|
+
throw new Error(`${header} Provided "encrypted" must decrypt to a non-empty string or buffer`);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
const decipher = (0, crypto_1.createDecipheriv)("aes-256-ctr", sha256.digest(), input.slice(0, 16));
|
58
|
+
const ciphertext = input.slice(16);
|
59
|
+
let output;
|
60
|
+
if (isString) {
|
61
|
+
// @ts-expect-error
|
62
|
+
output = decipher.update(ciphertext) + decipher.final();
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
// @ts-expect-error
|
66
|
+
output = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
67
|
+
}
|
68
|
+
return output;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
exports.AES = AES;
|
@@ -0,0 +1,136 @@
|
|
1
|
+
import { ComponentType } from "discord-api-types/v10";
|
2
|
+
import type { ButtonOptions, ModalOptions, SelectOptions, Slash, SlashOptions, TextInputOptions } from "../interfaces";
|
3
|
+
export declare const ButtonStyle: {
|
4
|
+
PRIMARY: number;
|
5
|
+
BLURPLE: number;
|
6
|
+
SECONDARY: number;
|
7
|
+
GREY: number;
|
8
|
+
SUCCESS: number;
|
9
|
+
GREEN: number;
|
10
|
+
DANGER: number;
|
11
|
+
RED: number;
|
12
|
+
LINK: number;
|
13
|
+
URL: number;
|
14
|
+
};
|
15
|
+
export declare const Interactions: {
|
16
|
+
button: (options?: ButtonOptions) => {
|
17
|
+
custom_id: string;
|
18
|
+
label: string;
|
19
|
+
type: number;
|
20
|
+
style: 1 | 2 | 3 | 4 | 5;
|
21
|
+
disabled: boolean;
|
22
|
+
emoji: {
|
23
|
+
name?: string | null | undefined;
|
24
|
+
id?: string | null | undefined;
|
25
|
+
animated?: boolean | undefined;
|
26
|
+
} | undefined;
|
27
|
+
url: string | undefined;
|
28
|
+
};
|
29
|
+
select: (options?: SelectOptions) => {
|
30
|
+
custom_id: string;
|
31
|
+
placeholder: string;
|
32
|
+
min_values: number;
|
33
|
+
max_values: number;
|
34
|
+
options: never[];
|
35
|
+
type: number;
|
36
|
+
disabled: boolean;
|
37
|
+
};
|
38
|
+
modal: (options?: ModalOptions) => {
|
39
|
+
custom_id: string;
|
40
|
+
title: string;
|
41
|
+
components: {
|
42
|
+
type: 1 | ComponentType.ActionRow;
|
43
|
+
components: import("discord-api-types/v10").APITextInputComponent[];
|
44
|
+
}[];
|
45
|
+
};
|
46
|
+
textInput: (options?: TextInputOptions, row?: boolean) => {
|
47
|
+
type: number;
|
48
|
+
custom_id: string;
|
49
|
+
style: number;
|
50
|
+
label: string;
|
51
|
+
min_length: number;
|
52
|
+
max_length: number;
|
53
|
+
placeholder: string;
|
54
|
+
value: string;
|
55
|
+
required: boolean;
|
56
|
+
} | {
|
57
|
+
type: number;
|
58
|
+
components: {
|
59
|
+
type: number;
|
60
|
+
custom_id: string;
|
61
|
+
style: number;
|
62
|
+
label: string;
|
63
|
+
min_length: number;
|
64
|
+
max_length: number;
|
65
|
+
placeholder: string;
|
66
|
+
value: string;
|
67
|
+
required: boolean;
|
68
|
+
}[];
|
69
|
+
};
|
70
|
+
};
|
71
|
+
export declare const Duration: {
|
72
|
+
parse: (value: string) => number | null;
|
73
|
+
determineTimeType: (str: string) => number;
|
74
|
+
validate: (value: string) => boolean;
|
75
|
+
timeIds: Set<string>;
|
76
|
+
};
|
77
|
+
export declare const SlashBuilder: {
|
78
|
+
TEXT_BASED_CHANNELS: number[];
|
79
|
+
types: {
|
80
|
+
sub_command: number;
|
81
|
+
sub_group: number;
|
82
|
+
string: number;
|
83
|
+
integer: number;
|
84
|
+
boolean: number;
|
85
|
+
user: number;
|
86
|
+
channel: number;
|
87
|
+
role: number;
|
88
|
+
mentionable: number;
|
89
|
+
number: number;
|
90
|
+
context: {
|
91
|
+
user: number;
|
92
|
+
message: number;
|
93
|
+
};
|
94
|
+
};
|
95
|
+
context: {
|
96
|
+
user: (name: string, options: object) => {
|
97
|
+
name: string;
|
98
|
+
description: string;
|
99
|
+
name_localizations: Record<string, string> | undefined;
|
100
|
+
description_localizations: Record<string, string> | undefined;
|
101
|
+
options: unknown[];
|
102
|
+
type: number;
|
103
|
+
dm_permission: boolean;
|
104
|
+
default_member_permissions: string;
|
105
|
+
};
|
106
|
+
message: (name: string, options: object) => {
|
107
|
+
name: string;
|
108
|
+
description: string;
|
109
|
+
name_localizations: Record<string, string> | undefined;
|
110
|
+
description_localizations: Record<string, string> | undefined;
|
111
|
+
options: unknown[];
|
112
|
+
type: number;
|
113
|
+
dm_permission: boolean;
|
114
|
+
default_member_permissions: string;
|
115
|
+
};
|
116
|
+
};
|
117
|
+
choice: (name: string, value: string, name_localizations: Record<string, string>) => {
|
118
|
+
name: string;
|
119
|
+
value: string;
|
120
|
+
name_localizations: Record<string, string>;
|
121
|
+
};
|
122
|
+
option: (data: SlashOptions) => SlashOptions & {
|
123
|
+
name_localizations: Record<string, string>;
|
124
|
+
description_localizations: Record<string, string>;
|
125
|
+
};
|
126
|
+
create: (name: string, description: string, options?: Slash) => {
|
127
|
+
name: string;
|
128
|
+
description: string;
|
129
|
+
name_localizations: Record<string, string> | undefined;
|
130
|
+
description_localizations: Record<string, string> | undefined;
|
131
|
+
options: unknown[];
|
132
|
+
type: number;
|
133
|
+
dm_permission: boolean;
|
134
|
+
default_member_permissions: string;
|
135
|
+
};
|
136
|
+
};
|