kythia-core 0.9.4-beta.3 → 0.10.1-beta
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/.husky/pre-commit +4 -0
- package/README.md +13 -4
- package/biome.json +40 -0
- package/bun.lock +445 -0
- package/changelog.md +14 -0
- package/index.js +1 -3
- package/package.json +57 -44
- package/src/Kythia.js +530 -438
- package/src/KythiaClient.js +90 -49
- package/src/database/KythiaMigrator.js +116 -0
- package/src/database/KythiaModel.js +1519 -1004
- package/src/database/KythiaSequelize.js +104 -95
- package/src/database/KythiaStorage.js +117 -0
- package/src/database/ModelLoader.js +79 -0
- package/src/managers/AddonManager.js +1190 -934
- package/src/managers/EventManager.js +80 -75
- package/src/managers/InteractionManager.js +794 -543
- package/src/managers/ShutdownManager.js +200 -179
- package/src/structures/BaseCommand.js +40 -36
- package/src/utils/color.js +157 -153
- package/src/utils/formatter.js +81 -81
- package/src/utils/index.js +2 -2
- package/src/database/KythiaORM.js +0 -520
package/src/utils/color.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
const discordColors = {
|
|
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
|
-
|
|
2
|
+
Default: 0x000000,
|
|
3
|
+
White: 0xffffff,
|
|
4
|
+
Aqua: 0x1abc9c,
|
|
5
|
+
Green: 0x57f287,
|
|
6
|
+
Blue: 0x3498db,
|
|
7
|
+
Yellow: 0xfee75c,
|
|
8
|
+
Purple: 0x9b59b6,
|
|
9
|
+
LuminousVividPink: 0xe91e63,
|
|
10
|
+
Fuchsia: 0xeb459e,
|
|
11
|
+
Gold: 0xf1c40f,
|
|
12
|
+
Orange: 0xe67e22,
|
|
13
|
+
Red: 0xed4245,
|
|
14
|
+
Grey: 0x95a5a6,
|
|
15
|
+
Navy: 0x34495e,
|
|
16
|
+
DarkAqua: 0x11806a,
|
|
17
|
+
DarkGreen: 0x1f8b4c,
|
|
18
|
+
DarkBlue: 0x206694,
|
|
19
|
+
DarkPurple: 0x71368a,
|
|
20
|
+
DarkVividPink: 0xad1457,
|
|
21
|
+
DarkGold: 0xc27c0e,
|
|
22
|
+
DarkOrange: 0xa84300,
|
|
23
|
+
DarkRed: 0x992d22,
|
|
24
|
+
DarkGrey: 0x979c9f,
|
|
25
|
+
DarkerGrey: 0x7f8c8d,
|
|
26
|
+
LightGrey: 0xbcc0c0,
|
|
27
|
+
DarkNavy: 0x2c3e50,
|
|
28
|
+
Blurple: 0x5865f2,
|
|
29
|
+
Greyple: 0x99aab5,
|
|
30
|
+
DarkButNotBlack: 0x2c2f33,
|
|
31
|
+
NotQuiteBlack: 0x23272a,
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -39,138 +39,142 @@ const discordColors = {
|
|
|
39
39
|
* @returns {string|number|{r:number,g:number,b:number}} The converted color.
|
|
40
40
|
*/
|
|
41
41
|
function convertColor(input, { from, to }) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
function hexToRgb(hex) {
|
|
43
|
+
let h = hex.replace(/^#/, '');
|
|
44
|
+
if (h.length === 3) {
|
|
45
|
+
h = h
|
|
46
|
+
.split('')
|
|
47
|
+
.map((x) => x + x)
|
|
48
|
+
.join('');
|
|
49
|
+
}
|
|
50
|
+
if (!/^[0-9a-fA-F]{6}$/.test(h)) throw new Error('Invalid hex color');
|
|
51
|
+
return {
|
|
52
|
+
r: parseInt(h.slice(0, 2), 16),
|
|
53
|
+
g: parseInt(h.slice(2, 4), 16),
|
|
54
|
+
b: parseInt(h.slice(4, 6), 16),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
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
|
-
|
|
58
|
+
function rgbToHex({ r, g, b }) {
|
|
59
|
+
if (
|
|
60
|
+
typeof r !== 'number' ||
|
|
61
|
+
typeof g !== 'number' ||
|
|
62
|
+
typeof b !== 'number' ||
|
|
63
|
+
r < 0 ||
|
|
64
|
+
r > 255 ||
|
|
65
|
+
g < 0 ||
|
|
66
|
+
g > 255 ||
|
|
67
|
+
b < 0 ||
|
|
68
|
+
b > 255
|
|
69
|
+
)
|
|
70
|
+
throw new Error('Invalid RGB color');
|
|
71
|
+
return (
|
|
72
|
+
'#' +
|
|
73
|
+
[r, g, b]
|
|
74
|
+
.map((x) => {
|
|
75
|
+
const hex = x.toString(16);
|
|
76
|
+
return hex.length === 1 ? `0${hex}` : hex;
|
|
77
|
+
})
|
|
78
|
+
.join('')
|
|
79
|
+
.toUpperCase()
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
function hexToDecimal(hex) {
|
|
84
|
+
let h = hex.replace(/^#/, '');
|
|
85
|
+
if (h.length === 3) {
|
|
86
|
+
h = h
|
|
87
|
+
.split('')
|
|
88
|
+
.map((x) => x + x)
|
|
89
|
+
.join('');
|
|
90
|
+
}
|
|
91
|
+
if (!/^[0-9a-fA-F]{6}$/.test(h)) throw new Error('Invalid hex color');
|
|
92
|
+
return Number(`0x${h.toUpperCase()}`);
|
|
93
|
+
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
function decimalToHex(decimal) {
|
|
96
|
+
if (typeof decimal !== 'number' || decimal < 0 || decimal > 0xffffff)
|
|
97
|
+
throw new Error('Invalid decimal color');
|
|
98
|
+
let hex = decimal.toString(16).toUpperCase();
|
|
99
|
+
while (hex.length < 6) hex = `0${hex}`;
|
|
100
|
+
return `#${hex}`;
|
|
101
|
+
}
|
|
101
102
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
103
|
+
function rgbToDecimal({ r, g, b }) {
|
|
104
|
+
if (
|
|
105
|
+
typeof r !== 'number' ||
|
|
106
|
+
typeof g !== 'number' ||
|
|
107
|
+
typeof b !== 'number' ||
|
|
108
|
+
r < 0 ||
|
|
109
|
+
r > 255 ||
|
|
110
|
+
g < 0 ||
|
|
111
|
+
g > 255 ||
|
|
112
|
+
b < 0 ||
|
|
113
|
+
b > 255
|
|
114
|
+
)
|
|
115
|
+
throw new Error('Invalid RGB color');
|
|
116
|
+
return (r << 16) + (g << 8) + b;
|
|
117
|
+
}
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
function decimalToRgb(decimal) {
|
|
120
|
+
if (typeof decimal !== 'number' || decimal < 0 || decimal > 0xffffff)
|
|
121
|
+
throw new Error('Invalid decimal color');
|
|
122
|
+
return {
|
|
123
|
+
r: (decimal >> 16) & 0xff,
|
|
124
|
+
g: (decimal >> 8) & 0xff,
|
|
125
|
+
b: decimal & 0xff,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
126
128
|
|
|
127
|
-
|
|
129
|
+
if (from === to) return input;
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
let rgb, hex, decimal;
|
|
130
132
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
133
|
+
switch (from) {
|
|
134
|
+
case 'hex':
|
|
135
|
+
hex = input;
|
|
136
|
+
rgb = hexToRgb(hex);
|
|
137
|
+
decimal = hexToDecimal(hex);
|
|
138
|
+
break;
|
|
139
|
+
case 'rgb':
|
|
140
|
+
rgb = input;
|
|
141
|
+
hex = rgbToHex(rgb);
|
|
142
|
+
decimal = rgbToDecimal(rgb);
|
|
143
|
+
break;
|
|
144
|
+
case 'decimal':
|
|
145
|
+
decimal = input;
|
|
146
|
+
hex = decimalToHex(decimal);
|
|
147
|
+
rgb = decimalToRgb(decimal);
|
|
148
|
+
break;
|
|
149
|
+
case 'discord':
|
|
150
|
+
if (typeof input === 'string') {
|
|
151
|
+
const key = Object.keys(discordColors).find(
|
|
152
|
+
(k) => k.toLowerCase() === input.toLowerCase(),
|
|
153
|
+
);
|
|
154
|
+
if (!key) throw new Error(`Invalid Discord color name: ${input}`);
|
|
155
|
+
decimal = discordColors[key];
|
|
156
|
+
} else if (typeof input === 'number') {
|
|
157
|
+
decimal = input;
|
|
158
|
+
} else {
|
|
159
|
+
throw new Error('Invalid input type for Discord color');
|
|
160
|
+
}
|
|
161
|
+
hex = decimalToHex(decimal);
|
|
162
|
+
rgb = decimalToRgb(decimal);
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
throw new Error(`Invalid "from" color type: ${from}`);
|
|
166
|
+
}
|
|
163
167
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
switch (to) {
|
|
169
|
+
case 'hex':
|
|
170
|
+
return hex;
|
|
171
|
+
case 'rgb':
|
|
172
|
+
return rgb;
|
|
173
|
+
case 'decimal':
|
|
174
|
+
return decimal;
|
|
175
|
+
default:
|
|
176
|
+
throw new Error(`Invalid "to" color type: ${to}`);
|
|
177
|
+
}
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
module.exports = convertColor;
|
package/src/utils/formatter.js
CHANGED
|
@@ -4,47 +4,47 @@
|
|
|
4
4
|
* @returns {string} Converted text using tiny letters.
|
|
5
5
|
*/
|
|
6
6
|
function toTinyText(text) {
|
|
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
|
-
|
|
7
|
+
const normal = 'abcdefghijklmnopqrstuvwxyz';
|
|
8
|
+
const tiny = [
|
|
9
|
+
'ᴀ',
|
|
10
|
+
'ʙ',
|
|
11
|
+
'ᴄ',
|
|
12
|
+
'ᴅ',
|
|
13
|
+
'ᴇ',
|
|
14
|
+
'ғ',
|
|
15
|
+
'ɢ',
|
|
16
|
+
'ʜ',
|
|
17
|
+
'ɪ',
|
|
18
|
+
'ᴊ',
|
|
19
|
+
'ᴋ',
|
|
20
|
+
'ʟ',
|
|
21
|
+
'ᴍ',
|
|
22
|
+
'ɴ',
|
|
23
|
+
'ᴏ',
|
|
24
|
+
'ᴘ',
|
|
25
|
+
'ǫ',
|
|
26
|
+
'ʀ',
|
|
27
|
+
's',
|
|
28
|
+
'ᴛ',
|
|
29
|
+
'ᴜ',
|
|
30
|
+
'ᴠ',
|
|
31
|
+
'ᴡ',
|
|
32
|
+
'x',
|
|
33
|
+
'ʏ',
|
|
34
|
+
'ᴢ',
|
|
35
|
+
];
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
return text
|
|
38
|
+
.split('')
|
|
39
|
+
.map((char) => {
|
|
40
|
+
const lowerChar = char.toLowerCase();
|
|
41
|
+
const index = normal.indexOf(lowerChar);
|
|
42
|
+
if (index !== -1) {
|
|
43
|
+
return tiny[index];
|
|
44
|
+
}
|
|
45
|
+
return char;
|
|
46
|
+
})
|
|
47
|
+
.join('');
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -53,47 +53,47 @@ function toTinyText(text) {
|
|
|
53
53
|
* @returns {string} Converted text using bold tiny letters.
|
|
54
54
|
*/
|
|
55
55
|
function toTinyBoldText(text) {
|
|
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
|
-
|
|
56
|
+
const normal = 'abcdefghijklmnopqrstuvwxyz';
|
|
57
|
+
const tinyBold = [
|
|
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
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
return text
|
|
87
|
+
.split('')
|
|
88
|
+
.map((char) => {
|
|
89
|
+
const lowerChar = char.toLowerCase();
|
|
90
|
+
const index = normal.indexOf(lowerChar);
|
|
91
|
+
if (index !== -1) {
|
|
92
|
+
return tinyBold[index];
|
|
93
|
+
}
|
|
94
|
+
return char;
|
|
95
|
+
})
|
|
96
|
+
.join('');
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
module.export = { toTinyText, toTinyBoldText };
|
|
99
|
+
module.export = { toTinyText, toTinyBoldText };
|
package/src/utils/index.js
CHANGED