kythia-core 0.11.1-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 -93
  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 -396
  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 -1586
  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 -869
  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
package/src/Kythia.js DELETED
@@ -1,556 +0,0 @@
1
- /**
2
- * 🌸 Kythia Core Application (The Orchestrator)
3
- *
4
- * @file src/Kythia.js
5
- * @copyright © 2025 kenndeclouv
6
- * @assistant chaa & graa
7
- * @version 0.11.1-beta
8
- *
9
- * @description
10
- * The heart of the application lifecycle. This class acts as the central
11
- * Dependency Injection (DI) container and orchestrator for all subsystems.
12
- * It manages the startup sequence, module loading, and graceful shutdown procedures.
13
- *
14
- * ✨ Core Responsibilities:
15
- * - Lifecycle Management: Bootstrapping, Running, and Terminating the bot safely.
16
- * - IoC Container: Central hub for Services, Managers, and Database connections.
17
- * - Addon Orchestration: Loading and initializing modular addons dynamically.
18
- * - Event Dispatching: Routes Gateway events to appropriate handlers.
19
- */
20
-
21
- const { REST, Routes, Collection } = require('discord.js');
22
- const KythiaClient = require('./KythiaClient');
23
- const Sentry = require('@sentry/node');
24
- const figlet = require('figlet');
25
-
26
- const InteractionManager = require('./managers/InteractionManager');
27
- const ShutdownManager = require('./managers/ShutdownManager');
28
- const AddonManager = require('./managers/AddonManager');
29
- const EventManager = require('./managers/EventManager');
30
-
31
- const KythiaMigrator = require('./database/KythiaMigrator');
32
- // const ModelLoader = require('./database/ModelLoader');
33
- const bootModels = require('./database/ModelLoader');
34
- const KythiaModel = require('./database/KythiaModel');
35
-
36
- class Kythia {
37
- /**
38
- * 🏗️ Kythia Constructor
39
- * Initializes the Discord client, REST API, and dependency container.
40
- * Sets up manager instances (but doesn't start them yet).
41
- */
42
- constructor({
43
- config,
44
- logger,
45
- redis,
46
- sequelize,
47
- translator,
48
- models,
49
- helpers,
50
- utils,
51
- appRoot,
52
- }) {
53
- const missingDeps = [];
54
- if (!config) missingDeps.push('config');
55
- if (!logger) missingDeps.push('logger');
56
- if (!translator) {
57
- missingDeps.push('translator');
58
- } else {
59
- if (!translator.t) missingDeps.push('translator.t');
60
- if (!translator.loadLocales) missingDeps.push('translator.loadLocales');
61
- }
62
- if (missingDeps.length > 0) {
63
- console.error(
64
- `FATAL: Missing required dependencies: ${missingDeps.join(', ')}.`,
65
- );
66
- process.exit(1);
67
- }
68
- this.kythiaConfig = config;
69
- this.appRoot = appRoot || process.cwd();
70
-
71
- this.client = KythiaClient();
72
- this.client.commands = new Collection();
73
- this.rest = new REST({ version: '10' }).setToken(
74
- this.kythiaConfig.bot.token,
75
- );
76
-
77
- this.models = models;
78
- this.helpers = helpers;
79
- this.utils = utils;
80
-
81
- this.redis = redis;
82
- this.sequelize = sequelize;
83
-
84
- this.logger = logger;
85
- this.translator = translator;
86
-
87
- this.container = {
88
- client: this.client,
89
- sequelize: this.sequelize,
90
- logger: this.logger,
91
- t: this.translator.t,
92
- redis: this.redis,
93
- kythiaConfig: this.kythiaConfig,
94
- translator: this.translator,
95
-
96
- models: this.models,
97
- helpers: this.helpers,
98
- appRoot: this.appRoot,
99
- };
100
-
101
- this.client.container = this.container;
102
- this.client.cooldowns = new Collection();
103
-
104
- this.dbReadyHooks = [];
105
- this.clientReadyHooks = [];
106
-
107
- this.addonManager = null;
108
- this.interactionManager = null;
109
- this.eventManager = null;
110
- this.shutdownManager = null;
111
- }
112
-
113
- /**
114
- * 🔍 Check Required Config
115
- * Checks if all required configurations are set.
116
- * Throws an error if any required config is missing.
117
- */
118
- _checkRequiredConfig() {
119
- const requiredBotConfig = [
120
- ['bot', 'token'],
121
- ['bot', 'clientId'],
122
- ['bot', 'clientSecret'],
123
- ];
124
- const missingBotConfigs = [];
125
- for (const pathArr of requiredBotConfig) {
126
- let value = this.kythiaConfig;
127
- for (const key of pathArr) {
128
- value = value?.[key];
129
- }
130
- if (value === undefined || value === null || value === '') {
131
- missingBotConfigs.push(pathArr.join('.'));
132
- }
133
- }
134
-
135
- if (!this.kythiaConfig.db) this.kythiaConfig.db = {};
136
-
137
- let driver = this.kythiaConfig.db.driver;
138
- if (!driver || driver === '') {
139
- this.kythiaConfig.db.driver = 'sqlite';
140
- driver = 'sqlite';
141
- this.logger.info('💡 DB driver not specified. Defaulting to: sqlite');
142
- } else {
143
- driver = driver.toLowerCase();
144
- this.kythiaConfig.db.driver = driver;
145
- }
146
-
147
- if (driver === 'sqlite') {
148
- if (!this.kythiaConfig.db.name || this.kythiaConfig.db.name === '') {
149
- this.kythiaConfig.db.name = 'kythiadata.sqlite';
150
- }
151
- }
152
-
153
- const requiredDbConfig = [
154
- ['db', 'driver'],
155
- ['db', 'name'],
156
- ];
157
-
158
- if (driver !== 'sqlite') {
159
- requiredDbConfig.push(
160
- ['db', 'host'],
161
- ['db', 'port'],
162
- ['db', 'user'],
163
- ['db', 'pass'],
164
- );
165
- }
166
-
167
- const missingDbConfigs = [];
168
- for (const pathArr of requiredDbConfig) {
169
- let value = this.kythiaConfig;
170
- for (const key of pathArr) {
171
- value = value?.[key];
172
- }
173
- if (value === undefined || value === null || value === '') {
174
- missingDbConfigs.push(pathArr.join('.'));
175
- }
176
- }
177
-
178
- const missingConfigs = missingBotConfigs.concat(missingDbConfigs);
179
-
180
- if (missingConfigs.length > 0) {
181
- this.logger.error('❌ Required configurations are not set:');
182
- for (const missing of missingConfigs) {
183
- this.logger.error(` - ${missing}`);
184
- }
185
- process.exit(1);
186
- }
187
-
188
- this.logger.info('✔️ All required configurations are set');
189
- }
190
-
191
- /**
192
- * 🔘 Register Button Handler
193
- * Delegates to AddonManager
194
- * @param {string} customId - The customId of the button
195
- * @param {Function} handler - The handler function to execute
196
- */
197
- registerButtonHandler(customId, handler) {
198
- if (this.addonManager) {
199
- this.addonManager.registerButtonHandler(customId, handler);
200
- }
201
- }
202
-
203
- /**
204
- * 📝 Register Modal Handler
205
- * Delegates to AddonManager
206
- * @param {string} customIdPrefix - The prefix of the modal customId
207
- * @param {Function} handler - The handler function to execute
208
- */
209
- registerModalHandler(customIdPrefix, handler) {
210
- if (this.addonManager) {
211
- this.addonManager.registerModalHandler(customIdPrefix, handler);
212
- }
213
- }
214
- /**
215
- * 🟦 Register Select Menu Handler
216
- * Delegates to AddonManager
217
- * @param {string} customIdPrefix - The prefix of the select menu customId
218
- * @param {Function} handler - The handler function to execute
219
- */
220
- registerSelectMenuHandler(customIdPrefix, handler) {
221
- if (this.addonManager) {
222
- this.addonManager.registerSelectMenuHandler(customIdPrefix, handler);
223
- }
224
- }
225
-
226
- /**
227
- * 🛡️ Validate License (Stub)
228
- * Placeholder for license validation logic for addons.
229
- * @param {string} licenseKey - The license key to validate
230
- * @param {string} addonName - The name of the addon
231
- * @returns {Promise<boolean>} Always returns true (stub)
232
- */
233
- async _validateLicense() {
234
- return true;
235
- }
236
-
237
- /**
238
- * 🚀 Deploy Commands to Discord
239
- * Deploys all registered slash commands to Discord using the REST API.
240
- * @param {Array} commands - Array of command data to deploy
241
- */
242
- async _deployCommands(commands) {
243
- if (!commands || commands.length === 0) {
244
- this.logger.info('No commands to deploy.');
245
- return;
246
- }
247
- try {
248
- const { slash, user, message } = this._getCommandCounts(commands);
249
- const clientId = this.kythiaConfig.bot.clientId;
250
- const devGuildId = this.kythiaConfig.bot.devGuildId;
251
-
252
- if (
253
- this.kythiaConfig.env === 'dev' ||
254
- this.kythiaConfig.env === 'development'
255
- ) {
256
- if (!devGuildId) {
257
- this.logger.warn(
258
- '⚠️ devGuildId not set in config. Skipping guild command deployment.',
259
- );
260
- return;
261
- }
262
- this.logger.info(`🟠 Deploying to GUILD ${devGuildId}...`);
263
- await this.rest.put(
264
- Routes.applicationGuildCommands(clientId, devGuildId),
265
- { body: commands },
266
- );
267
- this.logger.info('✅ Guild commands deployed instantly!');
268
- } else {
269
- this.logger.info(`🟢 Deploying globally...`);
270
- await this.rest.put(Routes.applicationCommands(clientId), {
271
- body: commands,
272
- });
273
- this.logger.info('✅ Global commands deployed successfully!');
274
- if (devGuildId) {
275
- this.logger.info(
276
- `🧹 Clearing old commands from dev guild: ${devGuildId}...`,
277
- );
278
- try {
279
- await this.rest.put(
280
- Routes.applicationGuildCommands(clientId, devGuildId),
281
- { body: [] },
282
- );
283
- this.logger.info('✅ Dev guild commands cleared successfully.');
284
- } catch (err) {
285
- this.logger.warn(
286
- `⚠️ Could not clear dev guild commands (maybe it was already clean): ${err.message}`,
287
- );
288
- }
289
- }
290
- }
291
-
292
- this.logger.info(`⭕ All Slash Commands: ${commands.length}`);
293
- this.logger.info(`⭕ Top Level Slash Commands: ${slash}`);
294
- this.logger.info(`⭕ User Context Menu: ${user}`);
295
- this.logger.info(`⭕ Message Context Menu: ${message}`);
296
- this.logger.info('▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬');
297
- } catch (err) {
298
- this.logger.error('❌ Failed to deploy slash commands:', err);
299
- }
300
- }
301
-
302
- /**
303
- * 🧮 Count command types from JSON array
304
- * @param {Array} commandJsonArray - Array command data to be deployed
305
- * @returns {object} - Object containing counts { slash, user, message }
306
- * @private
307
- */
308
- _getCommandCounts(commandJsonArray) {
309
- const counts = { slash: 0, user: 0, message: 0 };
310
-
311
- if (!Array.isArray(commandJsonArray)) {
312
- this.logger.warn(
313
- 'commandJsonArray is not iterable. Returning zero counts.',
314
- );
315
- return counts;
316
- }
317
-
318
- for (const cmd of commandJsonArray) {
319
- switch (cmd?.type) {
320
- case 1:
321
- case undefined:
322
- counts.slash++;
323
- break;
324
- case 2:
325
- counts.user++;
326
- break;
327
- case 3:
328
- counts.message++;
329
- break;
330
- }
331
- }
332
- return counts;
333
- }
334
-
335
- /**
336
- * Adds a callback to be executed when the database is ready.
337
- * The callback will be executed after all database models have been synchronized.
338
- * @param {function} callback - Callback to be executed when the database is ready
339
- */
340
- addDbReadyHook(callback) {
341
- this.dbReadyHooks.push(callback);
342
- }
343
-
344
- /**
345
- * Adds a callback to be executed when the client is ready.
346
- * @param {function} callback - Callback to be executed when the client is ready
347
- */
348
- addClientReadyHook(callback) {
349
- this.clientReadyHooks.push(callback);
350
- }
351
-
352
- /**
353
- * 🌸 Start the Kythia Bot
354
- * Main orchestration method that:
355
- * 1. Initializes Redis cache
356
- * 2. Creates and starts all managers
357
- * 3. Loads addons via AddonManager
358
- * 4. Initializes database
359
- * 5. Sets up interaction and event handlers
360
- * 6. Deploys commands
361
- * 7. Logs in to Discord
362
- */
363
- async start() {
364
- const version = require('../package.json').version;
365
- const clc = require('cli-color');
366
- const figletText = (text, opts) =>
367
- new Promise((resolve, reject) => {
368
- figlet.text(text, opts, (err, data) => {
369
- if (err) reject(err);
370
- else resolve(data);
371
- });
372
- });
373
-
374
- try {
375
- const data = await figletText('KYTHIA', {
376
- font: 'ANSI Shadow',
377
- horizontalLayout: 'full',
378
- verticalLayout: 'full',
379
- });
380
-
381
- const infoLines = [
382
- clc.cyan('Created by kenndeclouv'),
383
- clc.cyan('Discord Support: ') + clc.underline('https://dsc.gg/kythia'),
384
- clc.cyan('Official Documentation: ') +
385
- clc.underline('https://docs.kythia.me'),
386
- '',
387
- clc.cyanBright(`Kythia version: ${version}`),
388
- '',
389
- clc.yellowBright('Respect my work by not removing the credit'),
390
- ];
391
-
392
- const rawInfoLines = infoLines.map((line) => clc.strip(line));
393
- const infoMaxLen = Math.max(...rawInfoLines.map((l) => l.length));
394
- const pad = 8;
395
- const borderWidth = infoMaxLen + pad * 2;
396
- const borderChar = clc.cyanBright('═');
397
- const sideChar = clc.cyanBright('║');
398
- const topBorder = clc.cyanBright(`╔${borderChar.repeat(borderWidth)}╗`);
399
- const bottomBorder = clc.cyanBright(
400
- `╚${borderChar.repeat(borderWidth)}╝`,
401
- );
402
- const emptyLine = sideChar + ' '.repeat(borderWidth) + sideChar;
403
-
404
- const figletLines = data.split('\n');
405
- const centeredFigletInBorder = figletLines
406
- .map((line) => {
407
- const rawLen = clc.strip(line).length;
408
- const spaces = ' '.repeat(
409
- Math.max(0, Math.floor((borderWidth - rawLen) / 2)),
410
- );
411
- return (
412
- sideChar +
413
- spaces +
414
- clc.cyanBright(line) +
415
- ' '.repeat(borderWidth - spaces.length - rawLen) +
416
- sideChar
417
- );
418
- })
419
- .join('\n');
420
-
421
- const centeredInfo = infoLines
422
- .map((line, idx) => {
423
- const raw = rawInfoLines[idx];
424
- const spaces = ' '.repeat(Math.floor((borderWidth - raw.length) / 2));
425
- return (
426
- sideChar +
427
- spaces +
428
- line +
429
- ' '.repeat(borderWidth - spaces.length - raw.length) +
430
- sideChar
431
- );
432
- })
433
- .join('\n');
434
-
435
- console.log(`\n${topBorder}`);
436
- console.log(emptyLine);
437
- console.log(centeredFigletInBorder);
438
- console.log(emptyLine);
439
- console.log(centeredInfo);
440
- console.log(emptyLine);
441
- console.log(`${bottomBorder}\n`);
442
- } catch (err) {
443
- this.logger.error('❌ Failed to render figlet banner:', err);
444
- }
445
-
446
- this.logger.info('🚀 Starting kythia...');
447
-
448
- if (this.kythiaConfig.sentry.dsn) {
449
- Sentry.init({
450
- dsn: this.kythiaConfig.sentry.dsn,
451
- tracesSampleRate: 1.0,
452
- profilesSampleRate: 1.0,
453
- });
454
- this.logger.info('✔️ Sentry Error Tracking is ACTIVE');
455
- } else {
456
- this.logger.warn(
457
- '🟠 Sentry DSN not found in config. Error tracking is INACTIVE.',
458
- );
459
- }
460
-
461
- this._checkRequiredConfig();
462
-
463
- try {
464
- const shouldDeploy = process.argv.includes('--deploy');
465
-
466
- this.logger.info('▬▬▬▬▬▬▬▬▬▬▬[ Load Locales & Fonts ]▬▬▬▬▬▬▬▬▬▬▬');
467
- this.translator.loadLocales();
468
- if (
469
- this.helpers?.fonts &&
470
- typeof this.helpers.fonts.loadFonts === 'function'
471
- ) {
472
- this.helpers.fonts.loadFonts({ logger: this.logger });
473
- }
474
-
475
- this.logger.info('▬▬▬▬▬▬▬▬▬▬▬▬▬▬[ Initialize Cache ]▬▬▬▬▬▬▬▬▬▬▬▬▬▬');
476
-
477
- this.logger.info('▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬[ Kythia Addons ]▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬');
478
- this.addonManager = new AddonManager({
479
- client: this.client,
480
- container: this.container,
481
- });
482
- const allCommands = await this.addonManager.loadAddons(this);
483
-
484
- this.logger.info('▬▬▬▬▬▬▬▬▬▬▬▬▬▬[ Connect Database ]▬▬▬▬▬▬▬▬▬▬▬▬▬▬');
485
- await this.sequelize.authenticate();
486
-
487
- await KythiaMigrator({
488
- sequelize: this.sequelize,
489
- container: this.container,
490
- logger: this.logger,
491
- });
492
-
493
- await bootModels(this, this.sequelize);
494
-
495
- this.logger.info('🪝 Attaching Cache Hooks...');
496
-
497
- KythiaModel.attachHooksToAllModels(this.sequelize, this.client);
498
-
499
- const handlers = this.addonManager.getHandlers();
500
- this.eventManager = new EventManager({
501
- client: this.client,
502
- container: this.container,
503
- eventHandlers: handlers.eventHandlers,
504
- });
505
- this.eventManager.initialize();
506
-
507
- this.interactionManager = new InteractionManager({
508
- client: this.client,
509
- container: this.container,
510
- handlers: handlers,
511
- });
512
- this.interactionManager.initialize();
513
-
514
- this.logger.info('▬▬▬▬▬▬▬▬▬▬▬▬▬[ Deploy Commands ]▬▬▬▬▬▬▬▬▬▬▬▬▬');
515
- if (shouldDeploy) {
516
- await this._deployCommands(allCommands);
517
- } else {
518
- this.logger.info(
519
- '⏭️ Skipping command deployment. Use --deploy flag to force update.',
520
- );
521
- }
522
-
523
- this.shutdownManager = new ShutdownManager({
524
- client: this.client,
525
- container: this.container,
526
- });
527
- this.shutdownManager.initialize();
528
-
529
- this.logger.info('▬▬▬▬▬▬▬▬▬▬▬[ Systems Initializing ]▬▬▬▬▬▬▬▬▬▬▬▬');
530
-
531
- this.client.once('clientReady', async (c) => {
532
- this.logger.info(`🌸 Logged in as ${this.client.user.tag}`);
533
- this.logger.info(
534
- `🚀 Executing ${this.clientReadyHooks.length} client-ready hooks...`,
535
- );
536
- for (const hook of this.clientReadyHooks) {
537
- try {
538
- await hook(c);
539
- } catch (error) {
540
- this.logger.error('Failed to execute a client-ready hook:', error);
541
- }
542
- }
543
- });
544
-
545
- await this.client.login(this.kythiaConfig.bot.token);
546
- } catch (error) {
547
- this.logger.error('❌ Kythia initialization failed:', error);
548
- if (this.kythiaConfig.sentry.dsn) {
549
- Sentry.captureException(error);
550
- }
551
- process.exit(1);
552
- }
553
- }
554
- }
555
-
556
- module.exports = Kythia;
@@ -1,93 +0,0 @@
1
- /**
2
- * 🌐 Optimized Discord Client Factory
3
- *
4
- * @file src/client/kythiaClient.js
5
- * @copyright © 2025 kenndeclouv
6
- * @assistant chaa & graa
7
- * @version 0.11.1-beta
8
- *
9
- * @description
10
- * Factory function that initializes the Discord.js Client with high-performance
11
- * memory management strategies tailored for VPS environments.
12
- *
13
- * ✨ Optimization Highlights:
14
- * - Rolling Buffer Cache: Limits GuildMember cache to active users (Rolling Window) to save RAM.
15
- * - Aggressive Sweepers: Periodically clears stale cache data every hour.
16
- * - Voice Priority: Always caches members connected to Voice Channels.
17
- * - Zero-Presence: Disables PresenceManager completely for maximum efficiency.
18
- */
19
-
20
- const { Client, GatewayIntentBits, Partials, Options } = require('discord.js');
21
-
22
- module.exports = function kythiaClient() {
23
- const client = new Client({
24
- intents: [
25
- GatewayIntentBits.Guilds,
26
- GatewayIntentBits.GuildMessages,
27
- GatewayIntentBits.MessageContent,
28
- GatewayIntentBits.GuildMembers,
29
- GatewayIntentBits.GuildModeration,
30
- GatewayIntentBits.GuildInvites,
31
- GatewayIntentBits.GuildVoiceStates,
32
- GatewayIntentBits.AutoModerationExecution,
33
- GatewayIntentBits.DirectMessages,
34
- GatewayIntentBits.DirectMessageReactions,
35
- GatewayIntentBits.DirectMessageTyping,
36
- GatewayIntentBits.GuildExpressions,
37
- ],
38
-
39
- partials: [
40
- Partials.Message,
41
- Partials.Channel,
42
- Partials.Reaction,
43
- Partials.User,
44
- Partials.GuildMember,
45
- ],
46
-
47
- makeCache: Options.cacheWithLimits({
48
- PresenceManager: 0,
49
-
50
- ThreadManager: {
51
- maxSize: 25,
52
- },
53
-
54
- GuildMemberManager: {
55
- maxSize: 200,
56
- keepOverLimit: (member) =>
57
- (client.user && member.id === client.user.id) ||
58
- (member.guild && member.id === member.guild.ownerId) ||
59
- (member.voice && member.voice.channelId !== null) ||
60
- member.roles.cache.size > 5,
61
- },
62
-
63
- UserManager: {
64
- maxSize: 1000,
65
- keepOverLimit: (user) => user.id === client.user.id,
66
- },
67
- }),
68
-
69
- sweepers: {
70
- ...Options.DefaultSweeperSettings,
71
- messages: {
72
- interval: 3600,
73
- lifetime: 1800,
74
- },
75
- threads: {
76
- interval: 3600,
77
- lifetime: 1800,
78
- },
79
-
80
- users: {
81
- interval: 3600,
82
-
83
- filter: () => (user) => {
84
- if (user.bot) return false;
85
- if (user.id === client.user.id) return false;
86
- return true;
87
- },
88
- },
89
- },
90
- });
91
-
92
- return client;
93
- };
@@ -1,68 +0,0 @@
1
- /**
2
- * 🏗️ Abstract Base Command
3
- *
4
- * @file src/cli/Command.js
5
- * @copyright © 2025 kenndeclouv
6
- * @assistant chaa & graa
7
- * @version 0.11.1-beta
8
- *
9
- * @description
10
- * The base class for all Kythia CLI commands. It enforces a standard structure
11
- * (signature, description, handle) and manages the integration with Commander.js.
12
- *
13
- * ✨ Core Features:
14
- * - Standardized Interface: Enforces `handle()` implementation.
15
- * - Flexible Parsing: Handles both Options and Arguments intelligently.
16
- * - Auto Registration: Simplifies wiring commands to the main program.
17
- */
18
-
19
- class Command {
20
- /**
21
- * The name and signature of the console command.
22
- * @type {string}
23
- */
24
- signature = '';
25
-
26
- /**
27
- * The console command description.
28
- * @type {string}
29
- */
30
- description = '';
31
-
32
- /**
33
- * Execute the console command.
34
- * @param {Object} options - The options object from Commander
35
- * @param {...any} args - Positional arguments (if any)
36
- */
37
- async handle(_options, ..._args) {
38
- throw new Error('Command must implement handle method');
39
- }
40
-
41
- /**
42
- * Register the command with the program.
43
- * @param {import('commander').Command} program
44
- */
45
- register(program) {
46
- const cmd = program
47
- .command(this.signature)
48
- .description(this.description)
49
- .action((...args) => {
50
- const _commandObj = args.pop();
51
- const opts = args.pop() || {};
52
-
53
- this.handle(opts, ...args);
54
- });
55
-
56
- this.configure(cmd);
57
- }
58
-
59
- /**
60
- * Configure additional options or arguments.
61
- * @param {import('commander').Command} cmd
62
- */
63
- configure(_cmd) {
64
- // Override to add options
65
- }
66
- }
67
-
68
- module.exports = Command;