kythia-core 0.11.0-beta → 0.12.0-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.
Files changed (260) hide show
  1. package/dist/Kythia.d.ts +45 -0
  2. package/dist/Kythia.d.ts.map +1 -0
  3. package/dist/Kythia.js +443 -0
  4. package/dist/Kythia.js.map +1 -0
  5. package/dist/KythiaClient.d.ts +3 -0
  6. package/dist/KythiaClient.d.ts.map +1 -0
  7. package/dist/KythiaClient.js +69 -0
  8. package/dist/KythiaClient.js.map +1 -0
  9. package/dist/cli/Command.d.ts +9 -0
  10. package/dist/cli/Command.d.ts.map +1 -0
  11. package/dist/cli/Command.js +19 -0
  12. package/dist/cli/Command.js.map +1 -0
  13. package/dist/cli/commands/CacheClearCommand.d.ts +8 -0
  14. package/dist/cli/commands/CacheClearCommand.d.ts.map +1 -0
  15. package/dist/cli/commands/CacheClearCommand.js +94 -0
  16. package/dist/cli/commands/CacheClearCommand.js.map +1 -0
  17. package/dist/cli/commands/LangCheckCommand.d.ts +7 -0
  18. package/dist/cli/commands/LangCheckCommand.d.ts.map +1 -0
  19. package/dist/cli/commands/LangCheckCommand.js +345 -0
  20. package/dist/cli/commands/LangCheckCommand.js.map +1 -0
  21. package/dist/cli/commands/LangTranslateCommand.d.ts +8 -0
  22. package/dist/cli/commands/LangTranslateCommand.d.ts.map +1 -0
  23. package/dist/cli/commands/LangTranslateCommand.js +221 -0
  24. package/dist/cli/commands/LangTranslateCommand.js.map +1 -0
  25. package/dist/cli/commands/MakeMigrationCommand.d.ts +7 -0
  26. package/dist/cli/commands/MakeMigrationCommand.d.ts.map +1 -0
  27. package/dist/cli/commands/MakeMigrationCommand.js +55 -0
  28. package/dist/cli/commands/MakeMigrationCommand.js.map +1 -0
  29. package/dist/cli/commands/MakeModelCommand.d.ts +7 -0
  30. package/dist/cli/commands/MakeModelCommand.d.ts.map +1 -0
  31. package/dist/cli/commands/MakeModelCommand.js +56 -0
  32. package/dist/cli/commands/MakeModelCommand.js.map +1 -0
  33. package/dist/cli/commands/MigrateCommand.d.ts +14 -0
  34. package/dist/cli/commands/MigrateCommand.d.ts.map +1 -0
  35. package/dist/cli/commands/MigrateCommand.js +190 -0
  36. package/dist/cli/commands/MigrateCommand.js.map +1 -0
  37. package/dist/cli/commands/NamespaceCommand.d.ts +7 -0
  38. package/dist/cli/commands/NamespaceCommand.d.ts.map +1 -0
  39. package/dist/cli/commands/NamespaceCommand.js +92 -0
  40. package/dist/cli/commands/NamespaceCommand.js.map +1 -0
  41. package/dist/cli/commands/StructureCommand.d.ts +7 -0
  42. package/dist/cli/commands/StructureCommand.d.ts.map +1 -0
  43. package/dist/cli/commands/StructureCommand.js +51 -0
  44. package/dist/cli/commands/StructureCommand.js.map +1 -0
  45. package/dist/cli/commands/UpversionCommand.d.ts +7 -0
  46. package/dist/cli/commands/UpversionCommand.d.ts.map +1 -0
  47. package/dist/cli/commands/UpversionCommand.js +68 -0
  48. package/dist/cli/commands/UpversionCommand.js.map +1 -0
  49. package/dist/cli/index.d.ts +3 -0
  50. package/dist/cli/index.d.ts.map +1 -0
  51. package/dist/cli/index.js +44 -0
  52. package/dist/cli/index.js.map +1 -0
  53. package/dist/cli/utils/db.d.ts +9 -0
  54. package/dist/cli/utils/db.d.ts.map +1 -0
  55. package/dist/cli/utils/db.js +90 -0
  56. package/dist/cli/utils/db.js.map +1 -0
  57. package/dist/database/KythiaMigrator.d.ts +4 -0
  58. package/dist/database/KythiaMigrator.d.ts.map +1 -0
  59. package/dist/database/KythiaMigrator.js +94 -0
  60. package/dist/database/KythiaMigrator.js.map +1 -0
  61. package/dist/database/KythiaModel.d.ts +83 -0
  62. package/dist/database/KythiaModel.d.ts.map +1 -0
  63. package/dist/database/KythiaModel.js +1121 -0
  64. package/dist/database/KythiaModel.js.map +1 -0
  65. package/dist/database/KythiaSequelize.d.ts +4 -0
  66. package/dist/database/KythiaSequelize.d.ts.map +1 -0
  67. package/dist/database/KythiaSequelize.js +99 -0
  68. package/dist/database/KythiaSequelize.js.map +1 -0
  69. package/dist/database/KythiaStorage.d.ts +21 -0
  70. package/dist/database/KythiaStorage.d.ts.map +1 -0
  71. package/dist/database/KythiaStorage.js +80 -0
  72. package/dist/database/KythiaStorage.js.map +1 -0
  73. package/dist/database/ModelLoader.d.ts +4 -0
  74. package/dist/database/ModelLoader.d.ts.map +1 -0
  75. package/dist/database/ModelLoader.js +54 -0
  76. package/dist/database/ModelLoader.js.map +1 -0
  77. package/dist/index.d.ts +10 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +36 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/lang/en.json +85 -0
  82. package/dist/managers/AddonManager.d.ts +45 -0
  83. package/dist/managers/AddonManager.d.ts.map +1 -0
  84. package/dist/managers/AddonManager.js +932 -0
  85. package/dist/managers/AddonManager.js.map +1 -0
  86. package/dist/managers/EventManager.d.ts +19 -0
  87. package/dist/managers/EventManager.d.ts.map +1 -0
  88. package/dist/managers/EventManager.js +55 -0
  89. package/dist/managers/EventManager.js.map +1 -0
  90. package/dist/managers/InteractionManager.d.ts +41 -0
  91. package/dist/managers/InteractionManager.d.ts.map +1 -0
  92. package/dist/managers/InteractionManager.js +441 -0
  93. package/dist/managers/InteractionManager.js.map +1 -0
  94. package/dist/managers/MiddlewareManager.d.ts +14 -0
  95. package/dist/managers/MiddlewareManager.d.ts.map +1 -0
  96. package/dist/managers/MiddlewareManager.js +75 -0
  97. package/dist/managers/MiddlewareManager.js.map +1 -0
  98. package/dist/managers/ShutdownManager.d.ts +22 -0
  99. package/dist/managers/ShutdownManager.d.ts.map +1 -0
  100. package/dist/managers/ShutdownManager.js +151 -0
  101. package/dist/managers/ShutdownManager.js.map +1 -0
  102. package/dist/managers/TranslatorManager.d.ts +19 -0
  103. package/dist/managers/TranslatorManager.d.ts.map +1 -0
  104. package/dist/managers/TranslatorManager.js +118 -0
  105. package/dist/managers/TranslatorManager.js.map +1 -0
  106. package/dist/middlewares/botPermissions.d.ts +4 -0
  107. package/dist/middlewares/botPermissions.d.ts.map +1 -0
  108. package/dist/middlewares/botPermissions.js +28 -0
  109. package/dist/middlewares/botPermissions.js.map +1 -0
  110. package/dist/middlewares/cooldown.d.ts +4 -0
  111. package/dist/middlewares/cooldown.d.ts.map +1 -0
  112. package/dist/middlewares/cooldown.js +42 -0
  113. package/dist/middlewares/cooldown.js.map +1 -0
  114. package/dist/middlewares/isInMainGuild.d.ts +4 -0
  115. package/dist/middlewares/isInMainGuild.d.ts.map +1 -0
  116. package/dist/middlewares/isInMainGuild.js +52 -0
  117. package/dist/middlewares/isInMainGuild.js.map +1 -0
  118. package/dist/middlewares/ownerOnly.d.ts +4 -0
  119. package/dist/middlewares/ownerOnly.d.ts.map +1 -0
  120. package/dist/middlewares/ownerOnly.js +24 -0
  121. package/dist/middlewares/ownerOnly.js.map +1 -0
  122. package/dist/middlewares/teamOnly.d.ts +4 -0
  123. package/dist/middlewares/teamOnly.d.ts.map +1 -0
  124. package/dist/middlewares/teamOnly.js +26 -0
  125. package/dist/middlewares/teamOnly.js.map +1 -0
  126. package/dist/middlewares/userPermissions.d.ts +4 -0
  127. package/dist/middlewares/userPermissions.d.ts.map +1 -0
  128. package/dist/middlewares/userPermissions.js +28 -0
  129. package/dist/middlewares/userPermissions.js.map +1 -0
  130. package/dist/middlewares/voteLocked.d.ts +4 -0
  131. package/dist/middlewares/voteLocked.d.ts.map +1 -0
  132. package/dist/middlewares/voteLocked.js +50 -0
  133. package/dist/middlewares/voteLocked.js.map +1 -0
  134. package/dist/structures/BaseCommand.d.ts +23 -0
  135. package/dist/structures/BaseCommand.d.ts.map +1 -0
  136. package/dist/structures/BaseCommand.js +42 -0
  137. package/dist/structures/BaseCommand.js.map +1 -0
  138. package/dist/types/AddonManager.d.ts +58 -0
  139. package/dist/types/AddonManager.d.ts.map +1 -0
  140. package/dist/types/AddonManager.js +3 -0
  141. package/dist/types/AddonManager.js.map +1 -0
  142. package/dist/types/DiscordHelpers.d.ts +7 -0
  143. package/dist/types/DiscordHelpers.d.ts.map +1 -0
  144. package/dist/types/DiscordHelpers.js +3 -0
  145. package/dist/types/DiscordHelpers.js.map +1 -0
  146. package/dist/types/EventManager.d.ts +10 -0
  147. package/dist/types/EventManager.d.ts.map +1 -0
  148. package/dist/types/EventManager.js +3 -0
  149. package/dist/types/EventManager.js.map +1 -0
  150. package/dist/types/InteractionManager.d.ts +35 -0
  151. package/dist/types/InteractionManager.d.ts.map +1 -0
  152. package/dist/types/InteractionManager.js +3 -0
  153. package/dist/types/InteractionManager.js.map +1 -0
  154. package/dist/types/KythiaClient.d.ts +9 -0
  155. package/dist/types/KythiaClient.d.ts.map +1 -0
  156. package/dist/types/KythiaClient.js +3 -0
  157. package/dist/types/KythiaClient.js.map +1 -0
  158. package/dist/types/KythiaConfig.d.ts +291 -0
  159. package/dist/types/KythiaConfig.d.ts.map +1 -0
  160. package/dist/types/KythiaConfig.js +3 -0
  161. package/dist/types/KythiaConfig.js.map +1 -0
  162. package/dist/types/KythiaContainer.d.ts +38 -0
  163. package/dist/types/KythiaContainer.d.ts.map +1 -0
  164. package/dist/types/KythiaContainer.js +3 -0
  165. package/dist/types/KythiaContainer.js.map +1 -0
  166. package/dist/types/KythiaLogger.d.ts +5 -0
  167. package/dist/types/KythiaLogger.d.ts.map +1 -0
  168. package/dist/types/KythiaLogger.js +3 -0
  169. package/dist/types/KythiaLogger.js.map +1 -0
  170. package/dist/types/KythiaMigrator.d.ts +9 -0
  171. package/dist/types/KythiaMigrator.d.ts.map +1 -0
  172. package/dist/types/KythiaMigrator.js +3 -0
  173. package/dist/types/KythiaMigrator.js.map +1 -0
  174. package/dist/types/KythiaModel.d.ts +31 -0
  175. package/dist/types/KythiaModel.d.ts.map +1 -0
  176. package/dist/types/KythiaModel.js +3 -0
  177. package/dist/types/KythiaModel.js.map +1 -0
  178. package/dist/types/KythiaOptions.d.ts +13 -0
  179. package/dist/types/KythiaOptions.d.ts.map +1 -0
  180. package/dist/types/KythiaOptions.js +3 -0
  181. package/dist/types/KythiaOptions.js.map +1 -0
  182. package/dist/types/KythiaSequelize.d.ts +13 -0
  183. package/dist/types/KythiaSequelize.d.ts.map +1 -0
  184. package/dist/types/KythiaSequelize.js +3 -0
  185. package/dist/types/KythiaSequelize.js.map +1 -0
  186. package/dist/types/KythiaStorage.d.ts +22 -0
  187. package/dist/types/KythiaStorage.d.ts.map +1 -0
  188. package/dist/types/KythiaStorage.js +3 -0
  189. package/dist/types/KythiaStorage.js.map +1 -0
  190. package/dist/types/MiddlewareManager.d.ts +14 -0
  191. package/dist/types/MiddlewareManager.d.ts.map +1 -0
  192. package/dist/types/MiddlewareManager.js +3 -0
  193. package/dist/types/MiddlewareManager.js.map +1 -0
  194. package/dist/types/ModelLoader.d.ts +8 -0
  195. package/dist/types/ModelLoader.d.ts.map +1 -0
  196. package/dist/types/ModelLoader.js +3 -0
  197. package/dist/types/ModelLoader.js.map +1 -0
  198. package/dist/types/ShutdownManager.d.ts +15 -0
  199. package/dist/types/ShutdownManager.d.ts.map +1 -0
  200. package/dist/types/ShutdownManager.js +3 -0
  201. package/dist/types/ShutdownManager.js.map +1 -0
  202. package/dist/types/TranslatorManager.d.ts +16 -0
  203. package/dist/types/TranslatorManager.d.ts.map +1 -0
  204. package/dist/types/TranslatorManager.js +3 -0
  205. package/dist/types/TranslatorManager.js.map +1 -0
  206. package/dist/types/index.d.ts +13 -0
  207. package/dist/types/index.d.ts.map +1 -0
  208. package/dist/types/index.js +29 -0
  209. package/dist/types/index.js.map +1 -0
  210. package/dist/utils/color.d.ts +15 -0
  211. package/dist/utils/color.d.ts.map +1 -0
  212. package/dist/utils/color.js +156 -0
  213. package/dist/utils/color.js.map +1 -0
  214. package/dist/utils/discord.d.ts +8 -0
  215. package/dist/utils/discord.d.ts.map +1 -0
  216. package/dist/utils/discord.js +53 -0
  217. package/dist/utils/discord.js.map +1 -0
  218. package/dist/utils/formatter.d.ts +3 -0
  219. package/dist/utils/formatter.d.ts.map +1 -0
  220. package/dist/utils/formatter.js +89 -0
  221. package/dist/utils/formatter.js.map +1 -0
  222. package/dist/utils/index.d.ts +12 -0
  223. package/dist/utils/index.d.ts.map +1 -0
  224. package/dist/utils/index.js +54 -0
  225. package/dist/utils/index.js.map +1 -0
  226. package/dist/utils/logger.d.ts +5 -0
  227. package/dist/utils/logger.d.ts.map +1 -0
  228. package/dist/utils/logger.js +150 -0
  229. package/dist/utils/logger.js.map +1 -0
  230. package/package.json +28 -6
  231. package/src/lang/en.json +85 -0
  232. package/changelog.md +0 -53
  233. package/index.js +0 -15
  234. package/src/Kythia.js +0 -556
  235. package/src/KythiaClient.js +0 -94
  236. package/src/cli/Command.js +0 -68
  237. package/src/cli/commands/CacheClearCommand.js +0 -136
  238. package/src/cli/commands/LangCheckCommand.js +0 -367
  239. package/src/cli/commands/LangTranslateCommand.js +0 -336
  240. package/src/cli/commands/MakeMigrationCommand.js +0 -82
  241. package/src/cli/commands/MakeModelCommand.js +0 -81
  242. package/src/cli/commands/MigrateCommand.js +0 -259
  243. package/src/cli/commands/NamespaceCommand.js +0 -112
  244. package/src/cli/commands/StructureCommand.js +0 -70
  245. package/src/cli/commands/UpversionCommand.js +0 -94
  246. package/src/cli/index.js +0 -69
  247. package/src/cli/utils/db.js +0 -117
  248. package/src/database/KythiaMigrator.js +0 -116
  249. package/src/database/KythiaModel.js +0 -1557
  250. package/src/database/KythiaSequelize.js +0 -128
  251. package/src/database/KythiaStorage.js +0 -117
  252. package/src/database/ModelLoader.js +0 -79
  253. package/src/managers/AddonManager.js +0 -1219
  254. package/src/managers/EventManager.js +0 -104
  255. package/src/managers/InteractionManager.js +0 -815
  256. package/src/managers/ShutdownManager.js +0 -218
  257. package/src/structures/BaseCommand.js +0 -53
  258. package/src/utils/color.js +0 -180
  259. package/src/utils/formatter.js +0 -99
  260. package/src/utils/index.js +0 -4
@@ -1,218 +0,0 @@
1
- /**
2
- * 🛑 Shutdown Manager
3
- *
4
- * @file src/managers/ShutdownManager.js
5
- * @copyright © 2025 kenndeclouv
6
- * @assistant chaa & graa
7
- * @version 0.11.0-beta
8
- *
9
- * @description
10
- * Handles graceful shutdown procedures including interval tracking,
11
- * component cleanup, and resource management.
12
- */
13
-
14
- const exitHook = require('async-exit-hook');
15
-
16
- class ShutdownManager {
17
- /**
18
- * 🏗️ ShutdownManager Constructor
19
- * @param {Object} client - Discord client instance
20
- * @param {Object} container - Dependency container
21
- */
22
- constructor({ client, container }) {
23
- this.client = client;
24
- this.container = container;
25
- this._activeIntervals = new Set();
26
- this._messagesWithActiveCollectors = new Set();
27
- this._collectorPatched = false;
28
- this._cleanupAttached = false;
29
-
30
- this.logger = this.container.logger;
31
- }
32
-
33
- /**
34
- * 🕵️‍♂️ [GLOBAL PATCH] Overrides global interval functions to track all active intervals.
35
- * This allows for a truly generic and scalable graceful shutdown of all timed tasks.
36
- */
37
- initializeGlobalIntervalTracker() {
38
- if (!this._activeIntervals) this._activeIntervals = new Set();
39
-
40
- const botInstance = this;
41
- const originalSetInterval = global.setInterval;
42
- const originalClearInterval = global.clearInterval;
43
-
44
- global.setInterval = function (...args) {
45
- const intervalId = originalSetInterval.apply(this, args);
46
-
47
- botInstance._activeIntervals.add(intervalId);
48
- return intervalId;
49
- };
50
-
51
- global.clearInterval = function (intervalId) {
52
- originalClearInterval.apply(this, [intervalId]);
53
-
54
- botInstance._activeIntervals.delete(intervalId);
55
- };
56
-
57
- this.logger.info(
58
- '✅ Global setInterval/clearInterval has been patched for tracking.',
59
- );
60
- }
61
-
62
- disableRecursively(components) {
63
- return components.map((comp) => {
64
- if (comp.components && Array.isArray(comp.components)) {
65
- comp.components = disableRecursively(comp.components);
66
- }
67
-
68
- if (comp.type === 2 || comp.type === 3 || comp.type >= 5) {
69
- return { ...comp, disabled: true };
70
- }
71
- return comp;
72
- });
73
- }
74
-
75
- /**
76
- * 🛑 [FINAL ARCHITECTURE v5] Manages ALL graceful shutdown procedures.
77
- * This version patches the core message sending/editing methods to automatically
78
- * track ANY message with components, regardless of how its interactions are handled.
79
- */
80
- initializeShutdownCollectors() {
81
- if (!this._messagesWithActiveCollectors)
82
- this._messagesWithActiveCollectors = new Set();
83
-
84
- if (!this._collectorPatched) {
85
- const origCreateCollector =
86
- require('discord.js').Message.prototype.createMessageComponentCollector;
87
- const botInstance = this;
88
-
89
- require('discord.js').Message.prototype.createMessageComponentCollector =
90
- function (...args) {
91
- const collector = origCreateCollector.apply(this, args);
92
-
93
- if (botInstance._messagesWithActiveCollectors) {
94
- botInstance._messagesWithActiveCollectors.add(this);
95
- }
96
-
97
- collector.once('end', () => {
98
- if (botInstance._messagesWithActiveCollectors) {
99
- botInstance._messagesWithActiveCollectors.delete(this);
100
- }
101
- });
102
-
103
- return collector;
104
- };
105
- this._collectorPatched = true;
106
- this.logger.info(
107
- '✅ Corrected collector-based component tracking has been patched.',
108
- );
109
- }
110
-
111
- if (!this._cleanupAttached) {
112
- const cleanupAndFlush = async (callback) => {
113
- this.logger.info('🛑 Graceful shutdown initiated...');
114
-
115
- if (this._activeIntervals && this._activeIntervals.size > 0) {
116
- this.logger.info(
117
- `🛑 Halting ${this._activeIntervals.size} active global intervals...`,
118
- );
119
- for (const intervalId of this._activeIntervals) {
120
- clearInterval(intervalId);
121
- }
122
- }
123
-
124
- const messagesToProcess = this._messagesWithActiveCollectors;
125
-
126
- if (messagesToProcess && messagesToProcess.size > 0) {
127
- this.logger.info(
128
- `🛑 Disabling components on up to ${messagesToProcess.size} messages.`,
129
- );
130
- const editPromises = [];
131
-
132
- for (const msg of messagesToProcess) {
133
- if (!msg.editable || !msg.components || msg.components.length === 0)
134
- continue;
135
- try {
136
- const rawComponents = msg.components.map((c) => c.toJSON());
137
- const disabledComponents = disableRecursively(rawComponents);
138
- editPromises.push(
139
- msg.edit({ components: disabledComponents }).catch(() => {}),
140
- );
141
- } catch (error) {
142
- this.logger.error(error);
143
- }
144
- }
145
- await Promise.allSettled(editPromises);
146
- }
147
- this.logger.info('✅ Component cleanup complete.');
148
-
149
- this.logger.info('🚰 Flushing remaining logs...');
150
- this.logger.on('finish', () => {
151
- console.log(
152
- '⏳ Logger has flushed. Kythia is now safely shutting down.',
153
- );
154
- if (callback) callback();
155
- });
156
- this.logger.end();
157
- setTimeout(() => {
158
- console.log('⏳ Logger flush timeout. Forcing exit.');
159
- if (callback) callback();
160
- }, 4000);
161
- };
162
-
163
- exitHook(cleanupAndFlush);
164
- process.on('unhandledRejection', (error) => {
165
- this.logger.error('‼️ UNHANDLED PROMISE REJECTION:', error);
166
- });
167
- process.on('uncaughtException', (error) => {
168
- this.logger.error('‼️ UNCAUGHT EXCEPTION! Bot will shutdown.', error);
169
- process.exit(1);
170
- });
171
-
172
- this._cleanupAttached = true;
173
- this.logger.info(
174
- '🛡️ Graceful shutdown and error handlers are now active.',
175
- );
176
- }
177
- }
178
-
179
- /**
180
- * Initialize all shutdown procedures
181
- */
182
- initialize() {
183
- this.initializeGlobalIntervalTracker();
184
- this.initializeShutdownCollectors();
185
- }
186
-
187
- /**
188
- * Get active intervals count
189
- * @returns {number} Number of active intervals
190
- */
191
- getActiveIntervalsCount() {
192
- return this._activeIntervals ? this._activeIntervals.size : 0;
193
- }
194
-
195
- /**
196
- * Get messages with active collectors count
197
- * @returns {number} Number of messages with active collectors
198
- */
199
- getActiveCollectorsCount() {
200
- return this._messagesWithActiveCollectors
201
- ? this._messagesWithActiveCollectors.size
202
- : 0;
203
- }
204
-
205
- /**
206
- * Force cleanup (for testing purposes)
207
- */
208
- forceCleanup() {
209
- if (this._activeIntervals) {
210
- for (const intervalId of this._activeIntervals) {
211
- clearInterval(intervalId);
212
- }
213
- this._activeIntervals.clear();
214
- }
215
- }
216
- }
217
-
218
- module.exports = ShutdownManager;
@@ -1,53 +0,0 @@
1
- /**
2
- * Base Command Structure
3
- * @class BaseCommand
4
- * @description Base class for all command types (slash commands, context menus, etc.)
5
- */
6
- class BaseCommand {
7
- /**
8
- * @param {Object} container - Dependency injection container
9
- */
10
- constructor(container) {
11
- if (!container) {
12
- throw new Error('Container is required for BaseCommand');
13
- }
14
-
15
- this.container = container;
16
- this.client = container.client;
17
- this.logger = container.logger;
18
- this.t = container.t;
19
- this.models = container.models;
20
- this.kythiaConfig = container.kythiaConfig;
21
- this.helpers = container.helpers;
22
-
23
- this.data = {
24
- name: 'base-command',
25
- description: 'Base command description',
26
- cooldown: 10,
27
- permissions: [],
28
- ownerOnly: false,
29
- teamOnly: false,
30
- guildOnly: false,
31
- };
32
- }
33
-
34
- /**
35
- * Main command execution method (must be implemented by child classes)
36
- * @param {import('discord.js').CommandInteraction} interaction - The interaction object
37
- * @returns {Promise<void>}
38
- */
39
- async execute(interaction) {
40
- if (interaction.options?.getSubcommand?.(false)) {
41
- this.logger.warn(
42
- `Command group ${this.constructor.name} execute called - this should be handled by subcommand`,
43
- );
44
- return;
45
- }
46
-
47
- throw new Error(
48
- `Execute method not implemented for ${this.constructor.name}`,
49
- );
50
- }
51
- }
52
-
53
- module.exports = BaseCommand;
@@ -1,180 +0,0 @@
1
- const discordColors = {
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
- };
33
-
34
- /**
35
- * Converts a color between multiple representations.
36
- *
37
- * @param {string|number|{r:number,g:number,b:number}} input - The input color value.
38
- * @param {{from:'hex'|'rgb'|'decimal'|'discord', to:'hex'|'rgb'|'decimal'}} options - Conversion options.
39
- * @returns {string|number|{r:number,g:number,b:number}} The converted color.
40
- */
41
- function convertColor(input, { from, to }) {
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
-
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
-
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
-
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
- }
102
-
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
- }
118
-
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
- }
128
-
129
- if (from === to) return input;
130
-
131
- let rgb, hex, decimal;
132
-
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
- }
167
-
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
- }
178
- }
179
-
180
- module.exports = convertColor;
@@ -1,99 +0,0 @@
1
- /**
2
- * Converts a string to a small-caps-like Unicode alphabet variant.
3
- * @param {string} text - Input text.
4
- * @returns {string} Converted text using tiny letters.
5
- */
6
- function toTinyText(text) {
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
-
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
- }
49
-
50
- /**
51
- * Converts a string to a bold Unicode alphabet variant approximating "tiny" bold.
52
- * @param {string} text - Input text.
53
- * @returns {string} Converted text using bold tiny letters.
54
- */
55
- function toTinyBoldText(text) {
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
-
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
- }
98
-
99
- module.export = { toTinyText, toTinyBoldText };
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- color: require('./color.js'),
3
- formatter: require('./formatter.js'),
4
- };