@spatulox/simplediscordbot 2.2.1 → 3.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/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -33,21 +23,21 @@ __export(index_exports, {
33
23
  Bot: () => Bot,
34
24
  BotEnv: () => BotEnv,
35
25
  ButtonManager: () => ButtonManager,
36
- CacheManager: () => CacheManager,
26
+ CacheManager: () => import_utils22.CacheManager,
37
27
  ComponentManager: () => ComponentManager,
38
28
  DiscordRegex: () => DiscordRegex,
39
29
  EmbedManager: () => EmbedManager,
40
- FileManager: () => FileManager,
30
+ FileManager: () => import_utils21.FileManager,
41
31
  GuildManager: () => GuildManager,
42
- Log: () => Log,
32
+ Log: () => import_utils24.Log,
43
33
  ModalFieldType: () => ModalFieldType,
44
34
  ModalManager: () => ModalManager,
45
35
  ReactionManager: () => ReactionManager,
46
36
  SelectMenuManager: () => SelectMenuManager,
47
37
  SimpleColor: () => SimpleColor,
48
38
  SimpleDiscordBotInfo: () => SimpleDiscordBotInfo,
49
- SimpleMutex: () => SimpleMutex,
50
- Time: () => Time,
39
+ SimpleMutex: () => import_utils25.SimpleMutex,
40
+ Time: () => import_utils23.Time,
51
41
  UserManager: () => UserManager,
52
42
  WebhookManager: () => WebhookManager
53
43
  });
@@ -55,297 +45,13 @@ module.exports = __toCommonJS(index_exports);
55
45
 
56
46
  // src/core/Bot.ts
57
47
  var import_discord6 = require("discord.js");
58
-
59
- // src/utils/UnitTime.ts
60
- var UnitTime = class {
61
- constructor(val) {
62
- this.val = val;
63
- }
64
- val;
65
- toMilliseconds() {
66
- return this.val;
67
- }
68
- toSeconds() {
69
- return this.val / 1e3;
70
- }
71
- toMinutes() {
72
- return this.val / (60 * 1e3);
73
- }
74
- toHours() {
75
- return this.val / (60 * 60 * 1e3);
76
- }
77
- toDays() {
78
- return this.val / (24 * 60 * 60 * 1e3);
79
- }
80
- toString() {
81
- return this.val.toString();
82
- }
83
- valueOf() {
84
- return this.val;
85
- }
86
- value() {
87
- return this.val;
88
- }
89
- };
90
- var Milliseconds = {
91
- MS_100: new UnitTime(100),
92
- MS_200: new UnitTime(200),
93
- MS_500: new UnitTime(500),
94
- MS_800: new UnitTime(800),
95
- MS_1000: new UnitTime(1e3)
96
- };
97
- var Seconds = {
98
- SEC_01: new UnitTime(1e3),
99
- SEC_02: new UnitTime(2e3),
100
- SEC_03: new UnitTime(3e3),
101
- SEC_04: new UnitTime(4e3),
102
- SEC_05: new UnitTime(5e3),
103
- SEC_06: new UnitTime(6e3),
104
- SEC_07: new UnitTime(7e3),
105
- SEC_08: new UnitTime(8e3),
106
- SEC_09: new UnitTime(9e3),
107
- SEC_10: new UnitTime(1e4),
108
- SEC_11: new UnitTime(11e3),
109
- SEC_12: new UnitTime(12e3),
110
- SEC_13: new UnitTime(13e3),
111
- SEC_14: new UnitTime(14e3),
112
- SEC_15: new UnitTime(15e3),
113
- SEC_16: new UnitTime(16e3),
114
- SEC_17: new UnitTime(17e3),
115
- SEC_18: new UnitTime(18e3),
116
- SEC_19: new UnitTime(19e3),
117
- SEC_20: new UnitTime(2e4),
118
- SEC_21: new UnitTime(21e3),
119
- SEC_22: new UnitTime(22e3),
120
- SEC_23: new UnitTime(23e3),
121
- SEC_24: new UnitTime(24e3),
122
- SEC_25: new UnitTime(25e3),
123
- SEC_26: new UnitTime(26e3),
124
- SEC_27: new UnitTime(27e3),
125
- SEC_28: new UnitTime(28e3),
126
- SEC_29: new UnitTime(29e3),
127
- SEC_30: new UnitTime(3e4),
128
- SEC_31: new UnitTime(31e3),
129
- SEC_32: new UnitTime(32e3),
130
- SEC_33: new UnitTime(33e3),
131
- SEC_34: new UnitTime(34e3),
132
- SEC_35: new UnitTime(35e3),
133
- SEC_36: new UnitTime(36e3),
134
- SEC_37: new UnitTime(37e3),
135
- SEC_38: new UnitTime(38e3),
136
- SEC_39: new UnitTime(39e3),
137
- SEC_40: new UnitTime(4e4),
138
- SEC_41: new UnitTime(41e3),
139
- SEC_42: new UnitTime(42e3),
140
- SEC_43: new UnitTime(43e3),
141
- SEC_44: new UnitTime(44e3),
142
- SEC_45: new UnitTime(45e3),
143
- SEC_46: new UnitTime(46e3),
144
- SEC_47: new UnitTime(47e3),
145
- SEC_48: new UnitTime(48e3),
146
- SEC_49: new UnitTime(49e3),
147
- SEC_50: new UnitTime(5e4),
148
- SEC_51: new UnitTime(51e3),
149
- SEC_52: new UnitTime(52e3),
150
- SEC_53: new UnitTime(53e3),
151
- SEC_54: new UnitTime(54e3),
152
- SEC_55: new UnitTime(55e3),
153
- SEC_56: new UnitTime(56e3),
154
- SEC_57: new UnitTime(57e3),
155
- SEC_58: new UnitTime(58e3),
156
- SEC_59: new UnitTime(59e3),
157
- SEC_60: new UnitTime(6e4)
158
- };
159
- var Minutes = {
160
- MIN_01: new UnitTime(6e4),
161
- MIN_02: new UnitTime(12e4),
162
- MIN_03: new UnitTime(18e4),
163
- MIN_04: new UnitTime(24e4),
164
- MIN_05: new UnitTime(3e5),
165
- MIN_06: new UnitTime(36e4),
166
- MIN_07: new UnitTime(42e4),
167
- MIN_08: new UnitTime(48e4),
168
- MIN_09: new UnitTime(54e4),
169
- MIN_10: new UnitTime(6e5),
170
- MIN_11: new UnitTime(66e4),
171
- MIN_12: new UnitTime(72e4),
172
- MIN_13: new UnitTime(78e4),
173
- MIN_14: new UnitTime(84e4),
174
- MIN_15: new UnitTime(9e5),
175
- MIN_16: new UnitTime(96e4),
176
- MIN_17: new UnitTime(102e4),
177
- MIN_18: new UnitTime(108e4),
178
- MIN_19: new UnitTime(114e4),
179
- MIN_20: new UnitTime(12e5),
180
- MIN_21: new UnitTime(126e4),
181
- MIN_22: new UnitTime(132e4),
182
- MIN_23: new UnitTime(138e4),
183
- MIN_24: new UnitTime(144e4),
184
- MIN_25: new UnitTime(15e5),
185
- MIN_26: new UnitTime(156e4),
186
- MIN_27: new UnitTime(162e4),
187
- MIN_28: new UnitTime(168e4),
188
- MIN_29: new UnitTime(174e4),
189
- MIN_30: new UnitTime(18e5),
190
- MIN_31: new UnitTime(186e4),
191
- MIN_32: new UnitTime(192e4),
192
- MIN_33: new UnitTime(198e4),
193
- MIN_34: new UnitTime(204e4),
194
- MIN_35: new UnitTime(21e5),
195
- MIN_36: new UnitTime(216e4),
196
- MIN_37: new UnitTime(222e4),
197
- MIN_38: new UnitTime(228e4),
198
- MIN_39: new UnitTime(234e4),
199
- MIN_40: new UnitTime(24e5),
200
- MIN_41: new UnitTime(246e4),
201
- MIN_42: new UnitTime(252e4),
202
- MIN_43: new UnitTime(258e4),
203
- MIN_44: new UnitTime(264e4),
204
- MIN_45: new UnitTime(27e5),
205
- MIN_46: new UnitTime(276e4),
206
- MIN_47: new UnitTime(282e4),
207
- MIN_48: new UnitTime(288e4),
208
- MIN_49: new UnitTime(294e4),
209
- MIN_50: new UnitTime(3e6),
210
- MIN_51: new UnitTime(306e4),
211
- MIN_52: new UnitTime(312e4),
212
- MIN_53: new UnitTime(318e4),
213
- MIN_54: new UnitTime(324e4),
214
- MIN_55: new UnitTime(33e5),
215
- MIN_56: new UnitTime(336e4),
216
- MIN_57: new UnitTime(342e4),
217
- MIN_58: new UnitTime(348e4),
218
- MIN_59: new UnitTime(354e4),
219
- MIN_60: new UnitTime(36e5)
220
- };
221
- var Hours = {
222
- HOUR_01: new UnitTime(36e5),
223
- HOUR_02: new UnitTime(72e5),
224
- HOUR_03: new UnitTime(108e5),
225
- HOUR_04: new UnitTime(144e5),
226
- HOUR_05: new UnitTime(18e6),
227
- HOUR_06: new UnitTime(216e5),
228
- HOUR_07: new UnitTime(252e5),
229
- HOUR_08: new UnitTime(288e5),
230
- HOUR_09: new UnitTime(324e5),
231
- HOUR_10: new UnitTime(36e6),
232
- HOUR_11: new UnitTime(396e5),
233
- HOUR_12: new UnitTime(432e5),
234
- HOUR_13: new UnitTime(468e5),
235
- HOUR_14: new UnitTime(504e5),
236
- HOUR_15: new UnitTime(54e6),
237
- HOUR_16: new UnitTime(576e5),
238
- HOUR_17: new UnitTime(612e5),
239
- HOUR_18: new UnitTime(648e5),
240
- HOUR_19: new UnitTime(684e5),
241
- HOUR_20: new UnitTime(72e6),
242
- HOUR_21: new UnitTime(756e5),
243
- HOUR_22: new UnitTime(792e5),
244
- HOUR_23: new UnitTime(828e5),
245
- HOUR_24: new UnitTime(864e5)
246
- };
247
- var Days = {
248
- DAY_01: new UnitTime(864e5),
249
- DAY_02: new UnitTime(1728e5),
250
- DAY_03: new UnitTime(2592e5),
251
- DAY_04: new UnitTime(3456e5),
252
- DAY_05: new UnitTime(432e6),
253
- DAY_06: new UnitTime(5184e5),
254
- DAY_07: new UnitTime(6048e5),
255
- DAY_08: new UnitTime(6912e5),
256
- DAY_09: new UnitTime(7776e5),
257
- DAY_10: new UnitTime(864e6)
258
- };
259
- var Time = {
260
- milisecond: Milliseconds,
261
- second: Seconds,
262
- minute: Minutes,
263
- hour: Hours,
264
- day: Days,
265
- get DAY() {
266
- const h = (/* @__PURE__ */ new Date()).getHours();
267
- return h >= 7 && h < 23;
268
- },
269
- get NIGHT() {
270
- return !this.DAY;
271
- }
272
- };
273
-
274
- // src/utils/Log.ts
275
- var Log = class {
276
- static getPrefix(level) {
277
- const now = /* @__PURE__ */ new Date();
278
- const timestamp = `[${now.toLocaleDateString()} - ${now.toLocaleTimeString()}]`;
279
- return `${timestamp} [${level.toUpperCase()}]`;
280
- }
281
- static info(message) {
282
- console.info(`${this.getPrefix("info")} ${message}`);
283
- }
284
- static warn(message) {
285
- console.warn(`${this.getPrefix("warn")} ${message}`);
286
- }
287
- static error(message) {
288
- console.error(`${this.getPrefix("error")} ${message}`);
289
- }
290
- static debug(message) {
291
- console.debug(`${this.getPrefix("debug")} ${message}`);
292
- }
293
- static table(data) {
294
- const prefix = this.getPrefix("table");
295
- console.info(`${prefix} Table output:`);
296
- console.table(data);
297
- }
298
- };
299
-
300
- // src/utils/InternetChecker.ts
301
- var InternetChecker = class {
302
- static TARGET = "https://one.one.one.one/";
303
- // Cloudflare DNS HTTPS
304
- static RETRY_TIME = Time.second.SEC_30;
305
- /**
306
- * Check internet connection towards 1.1.1.1 (Cloudflare DNS)
307
- * @param tries Number of attempts (0 = infini)
308
- */
309
- static async checkConnection(tries = 0) {
310
- let attempt = 0;
311
- Log.info(
312
- tries > 0 ? `HTTP ping ${this.TARGET} (max ${tries} attempts)...` : `HTTP ping ${this.TARGET} (infinite attempts)...`
313
- );
314
- while (tries === 0 || attempt < tries) {
315
- try {
316
- const controller = new AbortController();
317
- const timeoutId = setTimeout(() => controller.abort(), 5e3);
318
- const response = await fetch(this.TARGET, {
319
- method: "HEAD",
320
- signal: controller.signal,
321
- cache: "no-store"
322
- });
323
- clearTimeout(timeoutId);
324
- if (response.ok) {
325
- const latency = response.headers.get("x-response-time") || "<1ms";
326
- Log.info(`Internet connection OK (${latency})`);
327
- return true;
328
- }
329
- } catch (error) {
330
- attempt++;
331
- const errorMsg = error.name === "AbortError" ? "Timeout (5s)" : error.message || "Unknown";
332
- Log.warn(
333
- tries > 0 ? `Ping failed (${errorMsg}) - Attempt ${attempt}/${tries}` : `Ping failed (${errorMsg}) - Retrying in ${this.RETRY_TIME.toSeconds()} seconds...`
334
- );
335
- try {
336
- await new Promise((resolve2) => setTimeout(resolve2, this.RETRY_TIME.toMilliseconds()));
337
- } catch {
338
- Log.error("Retry delay failed.");
339
- }
340
- }
341
- }
342
- Log.error(`No response from ${this.TARGET} after all attempts.`);
343
- return false;
344
- }
345
- };
48
+ var import_utils3 = require("@spatulox/utils");
49
+ var import_utils4 = require("@spatulox/utils");
50
+ var import_utils5 = require("@spatulox/utils");
346
51
 
347
52
  // src/core/BotLog.ts
348
53
  var import_discord2 = require("discord.js");
54
+ var import_utils = require("@spatulox/utils");
349
55
 
350
56
  // src/manager/interactible/SelectMenuManager.ts
351
57
  var import_discord = require("discord.js");
@@ -499,7 +205,7 @@ var BotLog = class _BotLog {
499
205
  */
500
206
  static async initDiscordLogging() {
501
207
  if (!Bot.client.isReady()) {
502
- Log.warn("Client not ready for Discord logging init");
208
+ import_utils.Log.warn("Client not ready for Discord logging init");
503
209
  return;
504
210
  }
505
211
  const logTypes = [
@@ -516,10 +222,10 @@ var BotLog = class _BotLog {
516
222
  if (channel?.isTextBased()) {
517
223
  _BotLog[prop] = channel;
518
224
  } else {
519
- Log.warn(`${config.charAt(0).toUpperCase() + config.slice(1)} channel ${channelId} invalid`);
225
+ import_utils.Log.warn(`${config.charAt(0).toUpperCase() + config.slice(1)} channel ${channelId} invalid`);
520
226
  }
521
227
  } catch (error) {
522
- Log.error(`${config.charAt(0).toUpperCase() + config.slice(1)} channel fetch failed: ${error}`);
228
+ import_utils.Log.error(`${config.charAt(0).toUpperCase() + config.slice(1)} channel fetch failed: ${error}`);
523
229
  }
524
230
  }
525
231
  }
@@ -591,7 +297,7 @@ var BotLog = class _BotLog {
591
297
  if (content instanceof import_discord2.EmbedBuilder) {
592
298
  const text = content.data.description ?? content.data.title;
593
299
  if (text) {
594
- Log.info(text);
300
+ import_utils.Log.info(text);
595
301
  }
596
302
  msg = await channel.send({ embeds: [content] });
597
303
  } else if (SelectMenuManager.isSelectMenuList(content)) {
@@ -605,7 +311,7 @@ var BotLog = class _BotLog {
605
311
  msg = await channel.send(`[${timestamp}] [${prefix.toUpperCase()}] ${content}`);
606
312
  }
607
313
  } catch (error) {
608
- Log.error(`Failed to send to Discord channel: ${error}`);
314
+ import_utils.Log.error(`Failed to send to Discord channel: ${error}`);
609
315
  }
610
316
  return msg;
611
317
  }
@@ -616,7 +322,7 @@ var BotLog = class _BotLog {
616
322
  const logConfig = Bot.config?.log;
617
323
  if (!logConfig || logConfig.info.console) {
618
324
  if (typeof content == "string") {
619
- Log.info(content);
325
+ import_utils.Log.info(content);
620
326
  }
621
327
  }
622
328
  if (logConfig?.info.discord && this.logChannel) {
@@ -630,7 +336,7 @@ var BotLog = class _BotLog {
630
336
  const logConfig = Bot.config.log;
631
337
  if (!logConfig || logConfig.error.console) {
632
338
  if (typeof content == "string") {
633
- Log.error(content);
339
+ import_utils.Log.error(content);
634
340
  }
635
341
  }
636
342
  if (logConfig?.error.discord && this.errorChannel) {
@@ -644,7 +350,7 @@ var BotLog = class _BotLog {
644
350
  const logConfig = Bot.config.log;
645
351
  if (!logConfig || logConfig?.warn.console) {
646
352
  if (typeof content == "string") {
647
- Log.warn(content);
353
+ import_utils.Log.warn(content);
648
354
  }
649
355
  }
650
356
  if (logConfig?.warn.discord && this.warnChannel) {
@@ -659,7 +365,7 @@ var BotLog = class _BotLog {
659
365
  const logConfig = Bot.config.log;
660
366
  if (!logConfig || logConfig?.debug.console) {
661
367
  if (typeof content == "string") {
662
- Log.debug(content);
368
+ import_utils.Log.debug(content);
663
369
  }
664
370
  }
665
371
  if (logConfig?.debug.discord && this.debugChannel) {
@@ -818,6 +524,7 @@ var EmbedManager = class {
818
524
 
819
525
  // src/core/BotMessage.ts
820
526
  var import_discord5 = require("discord.js");
527
+ var import_utils2 = require("@spatulox/utils");
821
528
 
822
529
  // src/manager/builder/SendableComponentBuilder.ts
823
530
  var import_discord4 = require("discord.js");
@@ -883,13 +590,13 @@ var BotMessage = class {
883
590
  static async send(channel, content, component) {
884
591
  try {
885
592
  if (!channel) {
886
- Log.warn("Cannot send message: Invalid channel ID");
593
+ import_utils2.Log.warn("Cannot send message: Invalid channel ID");
887
594
  return null;
888
595
  }
889
596
  if (typeof channel === "string") {
890
597
  const fetchedChannel = Bot.client.channels.cache.get(channel);
891
598
  if (!fetchedChannel?.isTextBased()) {
892
- Log.warn(`Cannot send message : Invalid channel ID: ${channel}`);
599
+ import_utils2.Log.warn(`Cannot send message : Invalid channel ID: ${channel}`);
893
600
  return null;
894
601
  }
895
602
  channel = fetchedChannel;
@@ -919,14 +626,14 @@ var BotMessage = class {
919
626
  throw e;
920
627
  }
921
628
  } catch (e) {
922
- Log.error(`Cannot send message : ${e}`);
629
+ import_utils2.Log.error(`Cannot send message : ${e}`);
923
630
  return null;
924
631
  }
925
632
  }
926
633
  static async sendDM(userOrId, content, component) {
927
634
  try {
928
635
  if (!userOrId) {
929
- Log.warn("Cannot send DM: Invalid user / ID");
636
+ import_utils2.Log.warn("Cannot send DM: Invalid user / ID");
930
637
  return null;
931
638
  }
932
639
  let targetUser;
@@ -935,7 +642,7 @@ var BotMessage = class {
935
642
  } else {
936
643
  const fetchedUser = await Bot.client.users.fetch(userOrId);
937
644
  if (!fetchedUser) {
938
- Log.warn(`Cannot send DM: User not found for ID: ${userOrId}`);
645
+ import_utils2.Log.warn(`Cannot send DM: User not found for ID: ${userOrId}`);
939
646
  return null;
940
647
  }
941
648
  targetUser = fetchedUser;
@@ -952,7 +659,7 @@ var BotMessage = class {
952
659
  }
953
660
  return await targetUser.send(messageCreate);
954
661
  } catch (error) {
955
- Log.error(`Cannot send DM to ${userOrId}: ${error}`);
662
+ import_utils2.Log.error(`Cannot send DM to ${userOrId}: ${error}`);
956
663
  return null;
957
664
  }
958
665
  }
@@ -1056,7 +763,7 @@ var BotInteraction = class {
1056
763
  // package.json
1057
764
  var package_default = {
1058
765
  name: "@spatulox/simplediscordbot",
1059
- version: "2.2.0",
766
+ version: "2.2.2",
1060
767
  author: "Spatulox",
1061
768
  description: "Simple discord bot framework to set up a bot under 30 secondes",
1062
769
  exports: {
@@ -1078,7 +785,8 @@ var package_default = {
1078
785
  },
1079
786
  license: "MIT",
1080
787
  dependencies: {
1081
- "@spatulox/discord-interaction-manager": "^2.0.6"
788
+ "@spatulox/discord-interaction-manager": "^2.0.6",
789
+ "@spatulox/utils": "^0.1.1"
1082
790
  },
1083
791
  peerDependencies: {
1084
792
  "discord.js": "^14.26.0"
@@ -1138,16 +846,16 @@ var Bot = class _Bot {
1138
846
  return _Bot._config;
1139
847
  }
1140
848
  constructor(client, config = {}) {
1141
- Log.info("----------------------------------------------------");
1142
- Log.info("Starting Bot");
849
+ import_utils4.Log.info("----------------------------------------------------");
850
+ import_utils4.Log.info("Starting Bot");
1143
851
  _Bot.criticConfig = { dev: BotEnv.dev, token: BotEnv.token };
1144
852
  _Bot._config = config;
1145
853
  _Bot._client = client;
1146
854
  (async () => {
1147
- Log.info(`Using discord.js version: ${import_discord6.version}`);
1148
- Log.info(`Using simplediscordbot version: ${SimpleDiscordBotInfo.version}`);
1149
- Log.info("Trying to connect to Discord Servers");
1150
- await InternetChecker.checkConnection(3);
855
+ import_utils4.Log.info(`Using discord.js version: ${import_discord6.version}`);
856
+ import_utils4.Log.info(`Using simplediscordbot version: ${SimpleDiscordBotInfo.version}`);
857
+ import_utils4.Log.info("Trying to connect to Discord Servers");
858
+ await import_utils5.InternetChecker.checkConnection(3);
1151
859
  await this.login();
1152
860
  })();
1153
861
  }
@@ -1161,20 +869,20 @@ var Bot = class _Bot {
1161
869
  _Bot._client.on(import_discord6.Events.ClientReady, async () => {
1162
870
  if (_Bot._client.user) {
1163
871
  await _Bot.log.initDiscordLogging();
1164
- Log.info(`Connected on ${_Bot._client.guilds.cache.size} servers as ${_Bot._client.user.tag}`);
872
+ import_utils4.Log.info(`Connected on ${_Bot._client.guilds.cache.size} servers as ${_Bot._client.user.tag}`);
1165
873
  _Bot.log.info(EmbedManager.description("Bot Started"));
1166
874
  }
1167
875
  });
1168
876
  } catch (error) {
1169
- Log.error(`Connection error : ${error}. Trying again...`);
877
+ import_utils4.Log.error(`Connection error : ${error}. Trying again...`);
1170
878
  tries++;
1171
879
  await new Promise(
1172
- (resolve2) => setTimeout(resolve2, Time.second.SEC_03.toMilliseconds())
880
+ (resolve2) => setTimeout(resolve2, import_utils3.Time.second.SEC_03.toMilliseconds())
1173
881
  );
1174
882
  }
1175
883
  }
1176
884
  if (!success) {
1177
- Log.error("Impossible to connect the bot after 3 attempts");
885
+ import_utils4.Log.error("Impossible to connect the bot after 3 attempts");
1178
886
  return false;
1179
887
  }
1180
888
  return true;
@@ -1182,12 +890,12 @@ var Bot = class _Bot {
1182
890
  static setActivity(message, type) {
1183
891
  if (_Bot._client.user) {
1184
892
  _Bot._client.user.setActivity({ name: message, type });
1185
- Log.info(`Activity defined : ${message}`);
893
+ import_utils4.Log.info(`Activity defined : ${message}`);
1186
894
  }
1187
895
  }
1188
896
  static setRandomActivity(randomActivity, intervalMs = null) {
1189
897
  if (randomActivity.length == 0) {
1190
- Log.error("Bot.randomActivity = [{}] is empty");
898
+ import_utils4.Log.error("Bot.randomActivity = [{}] is empty");
1191
899
  return;
1192
900
  }
1193
901
  const pickRandom = () => {
@@ -1197,349 +905,32 @@ var Bot = class _Bot {
1197
905
  };
1198
906
  if (intervalMs === null) {
1199
907
  pickRandom();
1200
- Log.info(`Activity set ONCE`);
908
+ import_utils4.Log.info(`Activity set ONCE`);
1201
909
  return;
1202
910
  }
1203
911
  pickRandom();
1204
912
  setInterval(async () => {
1205
913
  pickRandom();
1206
914
  }, intervalMs);
1207
- Log.info(`Random activity started (every ${Math.round(intervalMs / 6e4)}min)`);
915
+ import_utils4.Log.info(`Random activity started (every ${Math.round(intervalMs / 6e4)}min)`);
1208
916
  return;
1209
917
  }
1210
918
  };
1211
919
 
1212
- // src/manager/FileManager.ts
1213
- var import_path = __toESM(require("path"));
1214
- var import_promises = __toESM(require("fs/promises"));
1215
- var FileManager = class {
1216
- /**
1217
- * Check if a file exist
1218
- * @param filePath File path with file name
1219
- * @returns true si le fichier existe, false sinon
1220
- */
1221
- static async fileExists(filePath) {
1222
- try {
1223
- await import_promises.default.access(filePath);
1224
- return true;
1225
- } catch {
1226
- return false;
1227
- }
1228
- }
1229
- /**
1230
- * Reads a JSON file synchronously.
1231
- * @param filePath Full path to the JSON file
1232
- * @returns Parsed JSON object or 'Error' string on failure
1233
- */
1234
- static async readJsonFile(filePath) {
1235
- try {
1236
- const data = await import_promises.default.readFile(filePath, "utf8");
1237
- return JSON.parse(data);
1238
- } catch (error) {
1239
- Log.error(`Failed to read JSON file ${filePath}: ${error}`);
1240
- return false;
1241
- }
1242
- }
1243
- /**
1244
- * Lists all directories in a given path.
1245
- * @param directoryPath Path to scan for directories
1246
- * @returns Array of directory names or false on error
1247
- */
1248
- static async listDirectories(directoryPath) {
1249
- try {
1250
- const files = await import_promises.default.readdir(directoryPath, { withFileTypes: true });
1251
- return files.filter((file) => file.isDirectory()).map((dir) => dir.name);
1252
- } catch (error) {
1253
- Log.error(`Failed to read directory ${directoryPath}: ${error}`);
1254
- return false;
1255
- }
1256
- }
1257
- /**
1258
- * Lists all JSON files in a directory.
1259
- * @param directoryPath Path to scan for JSON files
1260
- * @returns Array of JSON filenames or false on error
1261
- */
1262
- static async listJsonFiles(directoryPath) {
1263
- try {
1264
- const files = await import_promises.default.readdir(directoryPath);
1265
- return files.filter((file) => import_path.default.extname(file) === ".json");
1266
- } catch (error) {
1267
- Log.error(`Failed to read directory ${directoryPath}: ${error}`);
1268
- return false;
1269
- }
1270
- }
1271
- /**
1272
- * Lists files with specific extension in a directory.
1273
- * @param directoryPath Path to scan
1274
- * @param extension File extension (with or without dot)
1275
- * @returns Array of matching filenames or 'Error' string on failure
1276
- */
1277
- static async listFiles(directoryPath, extension) {
1278
- if (typeof directoryPath !== "string" || typeof extension !== "string") {
1279
- Log.error("Directory path and extension must be strings");
1280
- return false;
1281
- }
1282
- try {
1283
- let ext = extension;
1284
- if (ext.startsWith(".")) {
1285
- ext = ext.slice(1);
1286
- }
1287
- const files = await import_promises.default.readdir(directoryPath);
1288
- return files.filter((file) => import_path.default.extname(file) === `.${ext}`);
1289
- } catch (error) {
1290
- Log.error(`Failed to read directory ${directoryPath}: ${error}`);
1291
- return false;
1292
- }
1293
- }
1294
- /**
1295
- * Creates directory structure and writes JSON data to file.
1296
- * @param directoryPath Full directory path (creates if missing)
1297
- * @param filename Filename without extension
1298
- * @param data Data to write (JSON serializable)
1299
- * @param sendErrorToErrorChannel Send error to the error channel
1300
- * @returns true on success, false on failure
1301
- */
1302
- static async writeJsonFile(directoryPath, filename, data, sendErrorToErrorChannel = true) {
1303
- if (Array.isArray(data) && data.length === 1 && data[0] === "Error") {
1304
- Log.error(`Cannot save data for ${filename}: data contains 'Error'`);
1305
- return false;
1306
- }
1307
- try {
1308
- await import_promises.default.mkdir(directoryPath, { recursive: true });
1309
- if (!filename || filename.trim() === "") {
1310
- Log.error("Cannot write JSON file: empty filename");
1311
- return false;
1312
- }
1313
- const cleanFilename = filename.replace(/\.json$/i, "");
1314
- const filePath = import_path.default.join(directoryPath, `${cleanFilename}.json`);
1315
- const jsonContent = JSON.stringify(data, null, 2);
1316
- await import_promises.default.writeFile(filePath, jsonContent);
1317
- Log.info(`Successfully wrote data to ${filePath}`);
1318
- return true;
1319
- } catch (error) {
1320
- const cleanFilename = filename.replace(/\.json$/i, "") || "unknown";
1321
- if (sendErrorToErrorChannel) {
1322
- await Bot.log.info(EmbedManager.error(`Failed to write file ${directoryPath}/${cleanFilename}.json: ${error}`));
1323
- } else {
1324
- Log.error(`Failed to write file ${directoryPath}/${cleanFilename}.json: ${error}`);
1325
- }
1326
- return false;
1327
- }
1328
- }
1329
- /**
1330
- * Delete a file
1331
- * @param filePath Full file path
1332
- * @returns true si supprimé avec succès, false sinon
1333
- */
1334
- static async deleteFile(filePath) {
1335
- try {
1336
- if (!await this.fileExists(filePath)) {
1337
- Log.warn(`File does not exist: ${filePath}`);
1338
- return false;
1339
- }
1340
- await import_promises.default.unlink(filePath);
1341
- Log.info(`Successfully deleted file: ${filePath}`);
1342
- return true;
1343
- } catch (error) {
1344
- Log.error(`Failed to delete file ${filePath}: ${error}`);
1345
- return false;
1346
- }
1347
- }
1348
- };
1349
-
1350
- // src/manager/CacheManager.ts
1351
- var import_path2 = __toESM(require("path"));
1352
- var CacheManager = class {
1353
- static get cacheDir() {
1354
- let folderPath = "simplediscordbot";
1355
- if (Bot.config?.botName) {
1356
- folderPath = this.cleanCacheId(Bot.config?.botName?.toLowerCase()).replace(" ", "_");
1357
- }
1358
- return import_path2.default.join(process.cwd(), `.${folderPath}cache`);
1359
- }
1360
- static cleanCacheId(key) {
1361
- return key.replace(/[^a-zA-Z0-9_-]/g, "_");
1362
- }
1363
- static createFilePath(filename) {
1364
- return import_path2.default.join(this.cacheDir, `${filename}.json`);
1365
- }
1366
- /**
1367
- * New file with cache_id as name
1368
- * @param cache_id - id which become the cache file name
1369
- * @param initialData - optional initial data
1370
- * @returns true if success, false otherwise
1371
- */
1372
- static async createCache(cache_id, initialData = {}) {
1373
- if (!cache_id || typeof cache_id !== "string" || cache_id.trim() === "") {
1374
- Bot.log.error('"Key" to create a cache must be a non-empty string');
1375
- return false;
1376
- }
1377
- const cleanCacheId = cache_id.replace(/[^a-zA-Z0-9_-]/g, "_");
1378
- Bot.log.info(`Creating cache file: ${cleanCacheId}.json`);
1379
- return await FileManager.writeJsonFile(
1380
- this.cacheDir,
1381
- this.cleanCacheId(cache_id),
1382
- initialData,
1383
- true
1384
- );
1385
- }
1386
- /**
1387
- * Read cache data or create empty one
1388
- * @param cache_id
1389
- * @param default_data default data with default key/value This will be send back if the cache doesn't exist and need to be created
1390
- * @returns true if success, false otherwise
1391
- */
1392
- static async getOrCreateCache(cache_id, default_data) {
1393
- if (!cache_id || typeof cache_id !== "string" || cache_id.trim() === "") {
1394
- Log.error('"cache_id" to get or create a cache must be a non-empty string');
1395
- return false;
1396
- }
1397
- const cleanCacheId = this.cleanCacheId(cache_id);
1398
- const filePath = this.createFilePath(cleanCacheId);
1399
- if (await FileManager.fileExists(filePath)) {
1400
- Log.info(`Cache already exists: ${cleanCacheId}.json`);
1401
- return FileManager.readJsonFile(filePath);
1402
- }
1403
- Log.info(`Creating new cache file: ${this.cacheDir}/${cleanCacheId}.json`);
1404
- const res = await FileManager.writeJsonFile(
1405
- this.cacheDir,
1406
- cleanCacheId,
1407
- default_data,
1408
- false
1409
- );
1410
- return res ? default_data : false;
1411
- }
1412
- /**
1413
- * Read cache data
1414
- * @param cache_id - cache_id to read
1415
- * @returns Json data, false otherwise
1416
- */
1417
- static async readCache(cache_id) {
1418
- if (!cache_id || typeof cache_id !== "string") {
1419
- Bot.log.error('"Key" must be a string');
1420
- return false;
1421
- }
1422
- const cleanCacheId = this.cleanCacheId(cache_id);
1423
- const filePath = this.createFilePath(cleanCacheId);
1424
- if (!await FileManager.fileExists(filePath)) {
1425
- Log.debug(`Cache not found: ${cleanCacheId}.json`);
1426
- return false;
1427
- }
1428
- return await FileManager.readJsonFile(filePath);
1429
- }
1430
- /**
1431
- * Overwrite cache data with the new data
1432
- * @param cache_id - ID of the cache
1433
- * @param data - new data
1434
- * @returns true if success, false otherwise
1435
- */
1436
- static async writeCache(cache_id, data) {
1437
- if (!cache_id || typeof cache_id !== "string") {
1438
- Log.error("Cache ID must be a string");
1439
- return false;
1440
- }
1441
- const cleanCacheId = this.cleanCacheId(cache_id);
1442
- Bot.log.info(`Writing to cache: ${cleanCacheId}.json`);
1443
- return await FileManager.writeJsonFile(
1444
- this.cacheDir,
1445
- cleanCacheId,
1446
- data,
1447
- true
1448
- );
1449
- }
1450
- /**
1451
- * Update specific property of the cache
1452
- * @param cache_id - ID of the cache
1453
- * @param property - property to update, with key and value
1454
- * @returns true if success, false otherwise
1455
- */
1456
- static async updateCacheProperty(cache_id, property) {
1457
- const cacheData = await this.readCache(cache_id);
1458
- if (cacheData === false) {
1459
- Log.error(`Cache ${cache_id} not found`);
1460
- return false;
1461
- }
1462
- cacheData[property.key] = property.value;
1463
- return await this.writeCache(cache_id, cacheData);
1464
- }
1465
- /**
1466
- * Reset an entire cache
1467
- * @param cache_id - cache ID to reset
1468
- * @returns true if success, false otherwise
1469
- */
1470
- static async resetCache(cache_id) {
1471
- try {
1472
- const cleanCacheId = cache_id.replace(/[^a-zA-Z0-9_-]/g, "_");
1473
- await this.writeCache(cache_id, {});
1474
- Log.info(`Reset cache: ${cleanCacheId}.json`);
1475
- return true;
1476
- } catch (error) {
1477
- Log.error(`Failed to reset cache ${cache_id}: ${error}`);
1478
- return false;
1479
- }
1480
- }
1481
- /**
1482
- * Delete an entire cache
1483
- * @param cache_id - cache ID to delete
1484
- * @returns true if success, false otherwise
1485
- */
1486
- static async deleteCache(cache_id) {
1487
- try {
1488
- const cleanCacheId = cache_id.replace(/[^a-zA-Z0-9_-]/g, "_");
1489
- const filePath = this.createFilePath(cleanCacheId);
1490
- if (await FileManager.deleteFile(filePath)) {
1491
- Log.info(`Deleted cache: ${cleanCacheId}.json`);
1492
- return true;
1493
- }
1494
- return false;
1495
- } catch (error) {
1496
- Log.error(`Failed to delete cache ${cache_id}: ${error}`);
1497
- return false;
1498
- }
1499
- }
1500
- /**
1501
- * List every existing cache
1502
- * @returns Array of cache_id, false otherwise
1503
- */
1504
- static async listCaches() {
1505
- return await FileManager.listJsonFiles(this.cacheDir);
1506
- }
1507
- /**
1508
- * Clean cache data
1509
- * @returns true if success, false otherwise
1510
- */
1511
- static async clearAllCaches() {
1512
- try {
1513
- const caches = await this.listCaches();
1514
- if (caches === false || caches.length === 0) {
1515
- return true;
1516
- }
1517
- let success = true;
1518
- for (const cache of caches) {
1519
- const result = await this.deleteCache(cache.replace(".json", ""));
1520
- if (!result) success = false;
1521
- }
1522
- return success;
1523
- } catch (error) {
1524
- Log.error(`Failed to clear caches: ${error}`);
1525
- return false;
1526
- }
1527
- }
1528
- };
920
+ // src/index.ts
921
+ var import_utils21 = require("@spatulox/utils");
922
+ var import_utils22 = require("@spatulox/utils");
1529
923
 
1530
924
  // src/manager/messages/WebhookManager.ts
1531
925
  var import_discord7 = require("discord.js");
1532
- var import_promises2 = require("fs/promises");
1533
- var import_path3 = require("path");
926
+ var import_promises = require("fs/promises");
927
+ var import_path = require("path");
1534
928
  var WebhookManager = class {
1535
929
  constructor(client, name, avatarPathOrUrl) {
1536
930
  this.client = client;
1537
931
  this.name = name;
1538
932
  this.avatarPathOrUrl = avatarPathOrUrl;
1539
933
  }
1540
- client;
1541
- name;
1542
- avatarPathOrUrl;
1543
934
  webhook = null;
1544
935
  async getAvatar() {
1545
936
  if (!this.avatarPathOrUrl) return null;
@@ -1547,8 +938,8 @@ var WebhookManager = class {
1547
938
  return this.avatarPathOrUrl;
1548
939
  }
1549
940
  try {
1550
- const resolvedPath = (0, import_path3.resolve)(process.cwd(), this.avatarPathOrUrl);
1551
- return await (0, import_promises2.readFile)(resolvedPath);
941
+ const resolvedPath = (0, import_path.resolve)(process.cwd(), this.avatarPathOrUrl);
942
+ return await (0, import_promises.readFile)(resolvedPath);
1552
943
  } catch (error) {
1553
944
  Bot.log.warn(`Failed to load avatar from ${this.avatarPathOrUrl}: ${error}`);
1554
945
  return null;
@@ -1655,10 +1046,17 @@ var WebhookManager = class {
1655
1046
  }
1656
1047
  };
1657
1048
 
1049
+ // src/manager/messages/ReactionManager.ts
1050
+ var import_utils9 = require("@spatulox/utils");
1051
+
1658
1052
  // src/manager/guild/ChannelManager/GuildTextChannelManager.ts
1659
1053
  var import_discord8 = require("discord.js");
1660
1054
 
1055
+ // src/manager/guild/ChannelManager/GuildChannelManager.ts
1056
+ var import_utils7 = require("@spatulox/utils");
1057
+
1661
1058
  // src/manager/guild/ChannelManager/GuildMessageManager.ts
1059
+ var import_utils6 = require("@spatulox/utils");
1662
1060
  var GuildMessageManager = class {
1663
1061
  /**
1664
1062
  * Impl
@@ -1667,7 +1065,7 @@ var GuildMessageManager = class {
1667
1065
  try {
1668
1066
  const channel = await GuildTextChannelManager.find(channelId);
1669
1067
  if (!channel) {
1670
- Log.error(`Channel ${channelId} not found in guild`);
1068
+ import_utils6.Log.error(`Channel ${channelId} not found in guild`);
1671
1069
  return null;
1672
1070
  }
1673
1071
  let payload;
@@ -1680,7 +1078,7 @@ var GuildMessageManager = class {
1680
1078
  }
1681
1079
  return await channel.send(payload);
1682
1080
  } catch (error) {
1683
- Log.error(`Failed to send message to ${channelId}: ${error}`);
1081
+ import_utils6.Log.error(`Failed to send message to ${channelId}: ${error}`);
1684
1082
  throw error;
1685
1083
  }
1686
1084
  }
@@ -1691,15 +1089,15 @@ var GuildMessageManager = class {
1691
1089
  try {
1692
1090
  const channel = await GuildTextChannelManager.find(channelId);
1693
1091
  if (!channel) {
1694
- Log.error(`Channel ${channelId} not found`);
1092
+ import_utils6.Log.error(`Channel ${channelId} not found`);
1695
1093
  return false;
1696
1094
  }
1697
1095
  const message = await channel.messages.fetch(messageId);
1698
1096
  await message.delete();
1699
- Log.info(`Deleted message ${messageId} from ${channelId}`);
1097
+ import_utils6.Log.info(`Deleted message ${messageId} from ${channelId}`);
1700
1098
  return true;
1701
1099
  } catch (error) {
1702
- Log.error(`Failed to delete message ${messageId} from ${channelId}: ${error}`);
1100
+ import_utils6.Log.error(`Failed to delete message ${messageId} from ${channelId}: ${error}`);
1703
1101
  return false;
1704
1102
  }
1705
1103
  }
@@ -1710,14 +1108,14 @@ var GuildMessageManager = class {
1710
1108
  try {
1711
1109
  const channel = await GuildTextChannelManager.find(channelId);
1712
1110
  if (!channel) {
1713
- Log.error(`Channel ${channelId} not found`);
1111
+ import_utils6.Log.error(`Channel ${channelId} not found`);
1714
1112
  return [];
1715
1113
  }
1716
1114
  const messages = await channel.messages.fetch({ limit });
1717
- Log.info(`Fetched ${messages.size} messages from ${channelId}`);
1115
+ import_utils6.Log.info(`Fetched ${messages.size} messages from ${channelId}`);
1718
1116
  return Array.from(messages.values());
1719
1117
  } catch (error) {
1720
- Log.error(`Failed to fetch messages from ${channelId}: ${error}`);
1118
+ import_utils6.Log.error(`Failed to fetch messages from ${channelId}: ${error}`);
1721
1119
  return [];
1722
1120
  }
1723
1121
  }
@@ -1728,13 +1126,13 @@ var GuildMessageManager = class {
1728
1126
  try {
1729
1127
  const channel = await GuildTextChannelManager.find(channelId);
1730
1128
  if (!channel) {
1731
- Log.error(`Channel ${channelId} not found`);
1129
+ import_utils6.Log.error(`Channel ${channelId} not found`);
1732
1130
  return null;
1733
1131
  }
1734
1132
  const message = await channel.messages.fetch(messageId);
1735
1133
  return message;
1736
1134
  } catch (error) {
1737
- Log.error(`Failed to fetch message ${messageId} from ${channelId}: ${error}`);
1135
+ import_utils6.Log.error(`Failed to fetch message ${messageId} from ${channelId}: ${error}`);
1738
1136
  return null;
1739
1137
  }
1740
1138
  }
@@ -1750,13 +1148,13 @@ var GuildChannelManager = class _GuildChannelManager {
1750
1148
  try {
1751
1149
  const guild = Bot.client.guilds.cache.get(guildId);
1752
1150
  if (!guild) {
1753
- Log.warn(`Guild ${guildId} not found`);
1151
+ import_utils7.Log.warn(`Guild ${guildId} not found`);
1754
1152
  return null;
1755
1153
  }
1756
1154
  const channel = await guild.channels.fetch(channelId);
1757
1155
  return channel ?? null;
1758
1156
  } catch (error) {
1759
- Log.error(`Failed to find channel ${channelId} in guild ${guildId}: ${error}`);
1157
+ import_utils7.Log.error(`Failed to find channel ${channelId} in guild ${guildId}: ${error}`);
1760
1158
  return null;
1761
1159
  }
1762
1160
  }
@@ -1766,10 +1164,10 @@ var GuildChannelManager = class _GuildChannelManager {
1766
1164
  if (cached && !cached.isDMBased()) return cached;
1767
1165
  const channel = await Bot.client.channels.fetch(channelId);
1768
1166
  if (channel && !channel.isDMBased()) return channel;
1769
- Log.warn(`Channel ${channelId} not found in any guild`);
1167
+ import_utils7.Log.warn(`Channel ${channelId} not found in any guild`);
1770
1168
  return null;
1771
1169
  } catch (error) {
1772
- Log.error(`Failed to find channel ${channelId}: ${error}`);
1170
+ import_utils7.Log.error(`Failed to find channel ${channelId}: ${error}`);
1773
1171
  return null;
1774
1172
  }
1775
1173
  }
@@ -1777,12 +1175,12 @@ var GuildChannelManager = class _GuildChannelManager {
1777
1175
  try {
1778
1176
  const guild = Bot.client.guilds.cache.get(guildId);
1779
1177
  if (!guild) {
1780
- Log.warn(`Guild ${guildId} not found`);
1178
+ import_utils7.Log.warn(`Guild ${guildId} not found`);
1781
1179
  return [];
1782
1180
  }
1783
1181
  return Array.from(guild.channels.cache.values());
1784
1182
  } catch (error) {
1785
- Log.error(`Failed to find channel ${guildId}: ${error}`);
1183
+ import_utils7.Log.error(`Failed to find channel ${guildId}: ${error}`);
1786
1184
  return [];
1787
1185
  }
1788
1186
  }
@@ -1793,14 +1191,14 @@ var GuildChannelManager = class _GuildChannelManager {
1793
1191
  try {
1794
1192
  const guild = Bot.client.guilds.cache.get(guildId);
1795
1193
  if (!guild) {
1796
- Log.warn(`Guild ${guildId} not found`);
1194
+ import_utils7.Log.warn(`Guild ${guildId} not found`);
1797
1195
  return [];
1798
1196
  }
1799
1197
  return Array.from(guild.channels.cache.values()).filter(
1800
1198
  (channel) => channel.name.toLowerCase().includes(name.toLowerCase())
1801
1199
  );
1802
1200
  } catch (error) {
1803
- Log.error(`Failed to find channel ${guildId}: ${error}`);
1201
+ import_utils7.Log.error(`Failed to find channel ${guildId}: ${error}`);
1804
1202
  return [];
1805
1203
  }
1806
1204
  }
@@ -1811,10 +1209,10 @@ var GuildChannelManager = class _GuildChannelManager {
1811
1209
  throw new Error(`Guild ${guildId} not found`);
1812
1210
  }
1813
1211
  const channel = await guild.channels.create(options);
1814
- Log.info(`Created channel ${channel.name} (${channel.id}) in guild ${guildId}`);
1212
+ import_utils7.Log.info(`Created channel ${channel.name} (${channel.id}) in guild ${guildId}`);
1815
1213
  return channel;
1816
1214
  } catch (error) {
1817
- Log.error(`Failed to create channel in guild ${guildId}: ${error}`);
1215
+ import_utils7.Log.error(`Failed to create channel in guild ${guildId}: ${error}`);
1818
1216
  throw error;
1819
1217
  }
1820
1218
  }
@@ -1825,16 +1223,17 @@ var GuildChannelManager = class _GuildChannelManager {
1825
1223
  throw new Error(`Channel ${channelId} not found`);
1826
1224
  }
1827
1225
  await channel.delete();
1828
- Log.info(`Deleted channel ${channelId}`);
1226
+ import_utils7.Log.info(`Deleted channel ${channelId}`);
1829
1227
  return true;
1830
1228
  } catch (error) {
1831
- Log.error(`Failed to delete channel ${channelId}: ${error}`);
1229
+ import_utils7.Log.error(`Failed to delete channel ${channelId}: ${error}`);
1832
1230
  throw error;
1833
1231
  }
1834
1232
  }
1835
1233
  };
1836
1234
 
1837
1235
  // src/manager/guild/ChannelManager/GuildTextChannelManager.ts
1236
+ var import_utils8 = require("@spatulox/utils");
1838
1237
  var GuildTextChannelManager = class extends GuildChannelManager {
1839
1238
  static async findInGuild(guildId, channelId) {
1840
1239
  const channel = await super.findInGuild(guildId, channelId);
@@ -1847,7 +1246,7 @@ var GuildTextChannelManager = class extends GuildChannelManager {
1847
1246
  static findAll(guildId) {
1848
1247
  const guild = Bot.client.guilds.cache.get(guildId);
1849
1248
  if (!guild) {
1850
- Log.warn(`Guild ${guildId} not found`);
1249
+ import_utils8.Log.warn(`Guild ${guildId} not found`);
1851
1250
  return [];
1852
1251
  }
1853
1252
  return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord8.TextChannel);
@@ -1877,9 +1276,9 @@ var ReactionManager = class {
1877
1276
  }
1878
1277
  const message = await channel.messages.fetch(messageId);
1879
1278
  await message.react(emoji);
1880
- Log.info(`Added reaction ${emoji} to message ${messageId}`);
1279
+ import_utils9.Log.info(`Added reaction ${emoji} to message ${messageId}`);
1881
1280
  } catch (error) {
1882
- Log.error(`Failed to add reaction to ${messageId}: ${error}`);
1281
+ import_utils9.Log.error(`Failed to add reaction to ${messageId}: ${error}`);
1883
1282
  throw error;
1884
1283
  }
1885
1284
  }
@@ -1899,9 +1298,9 @@ var ReactionManager = class {
1899
1298
  }
1900
1299
  const user = await Bot.client.users.fetch(userId);
1901
1300
  await reaction.users.remove(user);
1902
- Log.info(`Removed reaction ${emoji} from user ${userId} on message ${messageId}`);
1301
+ import_utils9.Log.info(`Removed reaction ${emoji} from user ${userId} on message ${messageId}`);
1903
1302
  } catch (error) {
1904
- Log.error(`Failed to remove reaction from ${messageId}: ${error}`);
1303
+ import_utils9.Log.error(`Failed to remove reaction from ${messageId}: ${error}`);
1905
1304
  throw error;
1906
1305
  }
1907
1306
  }
@@ -1925,10 +1324,10 @@ var ReactionManager = class {
1925
1324
  users: Array.from(users.values())
1926
1325
  });
1927
1326
  }
1928
- Log.info(`Fetched ${reactionList.length} reactions for message ${messageId}`);
1327
+ import_utils9.Log.info(`Fetched ${reactionList.length} reactions for message ${messageId}`);
1929
1328
  return reactionList;
1930
1329
  } catch (error) {
1931
- Log.error(`Failed to fetch reactions for ${messageId}: ${error}`);
1330
+ import_utils9.Log.error(`Failed to fetch reactions for ${messageId}: ${error}`);
1932
1331
  throw error;
1933
1332
  }
1934
1333
  }
@@ -1943,9 +1342,9 @@ var ReactionManager = class {
1943
1342
  }
1944
1343
  const message = await channel.messages.fetch(messageId);
1945
1344
  await message.reactions.removeAll();
1946
- Log.info(`Cleared all reactions from message ${messageId}`);
1345
+ import_utils9.Log.info(`Cleared all reactions from message ${messageId}`);
1947
1346
  } catch (error) {
1948
- Log.error(`Failed to clear reactions from ${messageId}: ${error}`);
1347
+ import_utils9.Log.error(`Failed to clear reactions from ${messageId}: ${error}`);
1949
1348
  throw error;
1950
1349
  }
1951
1350
  }
@@ -1953,9 +1352,15 @@ var ReactionManager = class {
1953
1352
 
1954
1353
  // src/manager/guild/GuildManager.ts
1955
1354
  var import_discord14 = require("discord.js");
1355
+ var import_utils18 = require("@spatulox/utils");
1356
+ var import_utils19 = require("@spatulox/utils");
1357
+
1358
+ // src/manager/guild/GuildUserManager.ts
1359
+ var import_utils11 = require("@spatulox/utils");
1956
1360
 
1957
1361
  // src/manager/direct/BasicUserManager.ts
1958
1362
  var import_discord9 = require("discord.js");
1363
+ var import_utils10 = require("@spatulox/utils");
1959
1364
  var BasicUserManager = class {
1960
1365
  /**
1961
1366
  * Find member in specific guild
@@ -1971,7 +1376,7 @@ var BasicUserManager = class {
1971
1376
  const cached = targetGuild.members.cache.get(memberId);
1972
1377
  if (cached) return cached;
1973
1378
  const member = await targetGuild.members.fetch(memberId).catch(() => null);
1974
- if (!member) Log.error(`UserManager: Member ${memberId} not found in guild ${targetGuild.id}`);
1379
+ if (!member) import_utils10.Log.error(`UserManager: Member ${memberId} not found in guild ${targetGuild.id}`);
1975
1380
  return member;
1976
1381
  }
1977
1382
  /**
@@ -2014,20 +1419,20 @@ var BasicUserManager = class {
2014
1419
  }
2015
1420
  const message = await dmChannel.send(payload);
2016
1421
  if (user instanceof import_discord9.GuildMember) {
2017
- Log.info(`Sent DM to ${user.id} (${user.user.username}): "${(payload.content || "Embed/Component").substring(0, 50)}..."`);
1422
+ import_utils10.Log.info(`Sent DM to ${user.id} (${user.user.username}): "${(payload.content || "Embed/Component").substring(0, 50)}..."`);
2018
1423
  } else {
2019
- Log.info(`Sent DM to ${user.id} (${user.username}): "${(payload.content || "Embed/Component").substring(0, 50)}..."`);
1424
+ import_utils10.Log.info(`Sent DM to ${user.id} (${user.username}): "${(payload.content || "Embed/Component").substring(0, 50)}..."`);
2020
1425
  }
2021
1426
  return message;
2022
1427
  } catch (error) {
2023
- Log.error(`Failed to send DM to ${user_id_or_user}: ${error}`);
1428
+ import_utils10.Log.error(`Failed to send DM to ${user_id_or_user}: ${error}`);
2024
1429
  throw new Error(`Cannot send DM to ${user_id_or_user}`);
2025
1430
  }
2026
1431
  }
2027
1432
  };
2028
1433
 
2029
1434
  // src/manager/guild/GuildUserManager.ts
2030
- var import_promises3 = require("timers/promises");
1435
+ var import_promises2 = require("timers/promises");
2031
1436
  var MAX_NICKNAME_LENGTH = 32;
2032
1437
  var GuildUserManager = class extends BasicUserManager {
2033
1438
  static async rename(member, nickname, maxAttempts = 3) {
@@ -2038,12 +1443,12 @@ var GuildUserManager = class extends BasicUserManager {
2038
1443
  try {
2039
1444
  const oldName = member.displayName;
2040
1445
  await member.setNickname(nickname.trim());
2041
- Log.info(`Renaming user: ${oldName} \u2192 ${nickname.trim()}`);
2042
- await (0, import_promises3.setTimeout)(1500);
1446
+ import_utils11.Log.info(`Renaming user: ${oldName} \u2192 ${nickname.trim()}`);
1447
+ await (0, import_promises2.setTimeout)(1500);
2043
1448
  return true;
2044
1449
  } catch (error) {
2045
1450
  console.error(`Attempt ${attempts + 1} failed when renaming ${member.displayName} into ${nickname.trim()}:`, error);
2046
- await (0, import_promises3.setTimeout)(1e3);
1451
+ await (0, import_promises2.setTimeout)(1e3);
2047
1452
  }
2048
1453
  }
2049
1454
  Bot.log.info(EmbedManager.error(`Failed to rename ${member.displayName} to ${nickname.trim()} after ${maxAttempts} attempts.`));
@@ -2056,13 +1461,13 @@ var GuildUserManager = class extends BasicUserManager {
2056
1461
  try {
2057
1462
  const guild = await GuildManager.find(guildId);
2058
1463
  if (!guild) {
2059
- Log.warn(`Guild ${guildId} not found`);
1464
+ import_utils11.Log.warn(`Guild ${guildId} not found`);
2060
1465
  return false;
2061
1466
  }
2062
1467
  const ban = await guild.bans.fetch(userId);
2063
1468
  return !!ban;
2064
1469
  } catch (error) {
2065
- Log.debug(`User ${userId} is not banned from guild ${guildId}`);
1470
+ import_utils11.Log.debug(`User ${userId} is not banned from guild ${guildId}`);
2066
1471
  return false;
2067
1472
  }
2068
1473
  }
@@ -2076,9 +1481,9 @@ var GuildUserManager = class extends BasicUserManager {
2076
1481
  throw new Error(`Member ${memberId} not found or not in a voice channel`);
2077
1482
  }
2078
1483
  await member.voice.disconnect();
2079
- Log.info(`Disconnected member ${memberId} from voice in guild ${guildId}`);
1484
+ import_utils11.Log.info(`Disconnected member ${memberId} from voice in guild ${guildId}`);
2080
1485
  } catch (error) {
2081
- Log.error(`Failed to disconnect member ${memberId} from voice in ${guildId}: ${error}`);
1486
+ import_utils11.Log.error(`Failed to disconnect member ${memberId} from voice in ${guildId}: ${error}`);
2082
1487
  throw error;
2083
1488
  }
2084
1489
  }
@@ -2093,7 +1498,7 @@ var GuildUserManager = class extends BasicUserManager {
2093
1498
  }
2094
1499
  return member.voice.channelId !== null;
2095
1500
  } catch (error) {
2096
- Log.debug(`Member ${memberId} not found or not in voice in guild ${guildId}`);
1501
+ import_utils11.Log.debug(`Member ${memberId} not found or not in voice in guild ${guildId}`);
2097
1502
  return false;
2098
1503
  }
2099
1504
  }
@@ -2107,9 +1512,9 @@ var GuildUserManager = class extends BasicUserManager {
2107
1512
  throw new Error(`User ${guildId} not found`);
2108
1513
  }
2109
1514
  await member.voice.setMute(true, reason);
2110
- Log.info(`Server muted ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
1515
+ import_utils11.Log.info(`Server muted ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
2111
1516
  } catch (error) {
2112
- Log.error(`Failed to server mute ${memberId} in ${guildId}:, error`);
1517
+ import_utils11.Log.error(`Failed to server mute ${memberId} in ${guildId}:, error`);
2113
1518
  throw error;
2114
1519
  }
2115
1520
  }
@@ -2123,9 +1528,9 @@ var GuildUserManager = class extends BasicUserManager {
2123
1528
  throw new Error(`User ${guildId} not found`);
2124
1529
  }
2125
1530
  await member.voice.setMute(false, reason);
2126
- Log.info(`Server unmuted ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
1531
+ import_utils11.Log.info(`Server unmuted ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
2127
1532
  } catch (error) {
2128
- Log.error(`Failed to server unmute ${memberId} in ${guildId}: ${error}`);
1533
+ import_utils11.Log.error(`Failed to server unmute ${memberId} in ${guildId}: ${error}`);
2129
1534
  throw error;
2130
1535
  }
2131
1536
  }
@@ -2139,9 +1544,9 @@ var GuildUserManager = class extends BasicUserManager {
2139
1544
  throw new Error(`User ${guildId} not found`);
2140
1545
  }
2141
1546
  await member.voice.setDeaf(true, reason);
2142
- Log.info(`Server deafened ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
1547
+ import_utils11.Log.info(`Server deafened ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
2143
1548
  } catch (error) {
2144
- Log.error(`Failed to server deafen ${memberId} in ${guildId}: ${error}`);
1549
+ import_utils11.Log.error(`Failed to server deafen ${memberId} in ${guildId}: ${error}`);
2145
1550
  throw error;
2146
1551
  }
2147
1552
  }
@@ -2155,9 +1560,9 @@ var GuildUserManager = class extends BasicUserManager {
2155
1560
  throw new Error(`User ${guildId} not found`);
2156
1561
  }
2157
1562
  await member.voice.setDeaf(false, reason);
2158
- Log.info(`Server undeafened ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
1563
+ import_utils11.Log.info(`Server undeafened ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
2159
1564
  } catch (error) {
2160
- Log.error(`Failed to server undeafen ${memberId} in ${guildId}: ${error}`);
1565
+ import_utils11.Log.error(`Failed to server undeafen ${memberId} in ${guildId}: ${error}`);
2161
1566
  throw error;
2162
1567
  }
2163
1568
  }
@@ -2172,9 +1577,9 @@ var GuildUserManager = class extends BasicUserManager {
2172
1577
  }
2173
1578
  const expires = Date.now() + duration;
2174
1579
  await member.timeout(expires, reason);
2175
- Log.info(`Timed out ${memberId} for ${duration}ms in guild ${guildId}: ${reason || "No reason"}`);
1580
+ import_utils11.Log.info(`Timed out ${memberId} for ${duration}ms in guild ${guildId}: ${reason || "No reason"}`);
2176
1581
  } catch (error) {
2177
- Log.error(`Failed to timeout ${memberId} in ${guildId}: ${error}`);
1582
+ import_utils11.Log.error(`Failed to timeout ${memberId} in ${guildId}: ${error}`);
2178
1583
  throw error;
2179
1584
  }
2180
1585
  }
@@ -2188,9 +1593,9 @@ var GuildUserManager = class extends BasicUserManager {
2188
1593
  throw new Error(`User ${guildId} not found`);
2189
1594
  }
2190
1595
  await member.timeout(null, reason);
2191
- Log.info(`Untimed out ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
1596
+ import_utils11.Log.info(`Untimed out ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
2192
1597
  } catch (error) {
2193
- Log.error(`Failed to untimeout ${memberId} in ${guildId}: ${error}`);
1598
+ import_utils11.Log.error(`Failed to untimeout ${memberId} in ${guildId}: ${error}`);
2194
1599
  throw error;
2195
1600
  }
2196
1601
  }
@@ -2204,9 +1609,9 @@ var GuildUserManager = class extends BasicUserManager {
2204
1609
  throw new Error(`User ${guildId} not found`);
2205
1610
  }
2206
1611
  await member.kick(reason);
2207
- Log.info(`Kicked ${memberId} from guild ${guildId}: ${reason || "No reason"}`);
1612
+ import_utils11.Log.info(`Kicked ${memberId} from guild ${guildId}: ${reason || "No reason"}`);
2208
1613
  } catch (error) {
2209
- Log.error(`Failed to kick ${memberId} from ${guildId}: ${error}`);
1614
+ import_utils11.Log.error(`Failed to kick ${memberId} from ${guildId}: ${error}`);
2210
1615
  throw error;
2211
1616
  }
2212
1617
  }
@@ -2217,9 +1622,9 @@ var GuildUserManager = class extends BasicUserManager {
2217
1622
  }
2218
1623
  try {
2219
1624
  await guild.members.ban(userId, banOption);
2220
- Log.info(`Banned user ${userId} from guild ${guildId}`);
1625
+ import_utils11.Log.info(`Banned user ${userId} from guild ${guildId}`);
2221
1626
  } catch (error) {
2222
- Log.error(`Failed to ban user ${userId} from guild ${guildId}: ${error}`);
1627
+ import_utils11.Log.error(`Failed to ban user ${userId} from guild ${guildId}: ${error}`);
2223
1628
  throw error;
2224
1629
  }
2225
1630
  }
@@ -2230,15 +1635,16 @@ var GuildUserManager = class extends BasicUserManager {
2230
1635
  }
2231
1636
  try {
2232
1637
  await guild.members.unban(userId, reason);
2233
- Log.info(`Unbanned user ${userId} from guild ${guildId}`);
1638
+ import_utils11.Log.info(`Unbanned user ${userId} from guild ${guildId}`);
2234
1639
  } catch (error) {
2235
- Log.error(`Failed to unban user ${userId} from guild ${guildId}: ${error}`);
1640
+ import_utils11.Log.error(`Failed to unban user ${userId} from guild ${guildId}: ${error}`);
2236
1641
  throw error;
2237
1642
  }
2238
1643
  }
2239
1644
  };
2240
1645
 
2241
1646
  // src/manager/guild/RoleManager.ts
1647
+ var import_utils12 = require("@spatulox/utils");
2242
1648
  var RoleManager = class {
2243
1649
  /**
2244
1650
  * Add role - CACHE ONLY
@@ -2249,14 +1655,14 @@ var RoleManager = class {
2249
1655
  try {
2250
1656
  const role = member.guild.roles.cache.get(roleId);
2251
1657
  if (!role) {
2252
- Log.warn(`Role ${roleId} not found in cache`);
1658
+ import_utils12.Log.warn(`Role ${roleId} not found in cache`);
2253
1659
  return false;
2254
1660
  }
2255
1661
  await member.roles.add(role);
2256
- Log.info(`\u2705 Added ${role.name} to ${member.displayName}`);
1662
+ import_utils12.Log.info(`\u2705 Added ${role.name} to ${member.displayName}`);
2257
1663
  return true;
2258
1664
  } catch (error) {
2259
- Log.error(`Failed to add role ${roleId}: ${error}`);
1665
+ import_utils12.Log.error(`Failed to add role ${roleId}: ${error}`);
2260
1666
  return false;
2261
1667
  }
2262
1668
  }
@@ -2276,14 +1682,14 @@ var RoleManager = class {
2276
1682
  );
2277
1683
  }
2278
1684
  if (!role) {
2279
- Log.warn(`Role ${roleIdOrName} not found for ${member.displayName}`);
1685
+ import_utils12.Log.warn(`Role ${roleIdOrName} not found for ${member.displayName}`);
2280
1686
  return false;
2281
1687
  }
2282
1688
  await member.roles.remove(role);
2283
- Log.info(`\u2705 Removed ${role.name} from ${member.displayName}`);
1689
+ import_utils12.Log.info(`\u2705 Removed ${role.name} from ${member.displayName}`);
2284
1690
  return true;
2285
1691
  } catch (error) {
2286
- Log.error(`Failed to remove role ${roleIdOrName}: ${error}`);
1692
+ import_utils12.Log.error(`Failed to remove role ${roleIdOrName}: ${error}`);
2287
1693
  return false;
2288
1694
  }
2289
1695
  }
@@ -2293,7 +1699,7 @@ var RoleManager = class {
2293
1699
  static async toggle(member, roleIdOrName) {
2294
1700
  const role = member.roles.cache.get(roleIdOrName) || member.roles.cache.find((r) => r.name.toLowerCase() === roleIdOrName.toString().toLowerCase());
2295
1701
  if (!role) {
2296
- Log.warn(`Role ${roleIdOrName} not found`);
1702
+ import_utils12.Log.warn(`Role ${roleIdOrName} not found`);
2297
1703
  throw new Error(`Role not found`);
2298
1704
  }
2299
1705
  if (member.roles.cache.has(role.id)) {
@@ -2319,6 +1725,7 @@ var RoleManager = class {
2319
1725
 
2320
1726
  // src/manager/guild/ChannelManager/ForumChannelManager.ts
2321
1727
  var import_discord10 = require("discord.js");
1728
+ var import_utils13 = require("@spatulox/utils");
2322
1729
  var ForumChannelManager = class extends GuildChannelManager {
2323
1730
  static async findInGuild(guildId, channelId) {
2324
1731
  const channel = await super.findInGuild(guildId, channelId);
@@ -2331,7 +1738,7 @@ var ForumChannelManager = class extends GuildChannelManager {
2331
1738
  static findAll(guildId) {
2332
1739
  const guild = Bot.client.guilds.cache.get(guildId);
2333
1740
  if (!guild) {
2334
- Log.warn(`Guild ${guildId} not found`);
1741
+ import_utils13.Log.warn(`Guild ${guildId} not found`);
2335
1742
  return [];
2336
1743
  }
2337
1744
  return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord10.ForumChannel);
@@ -2347,6 +1754,7 @@ var ForumChannelManager = class extends GuildChannelManager {
2347
1754
 
2348
1755
  // src/manager/guild/ChannelManager/NewsChannelManager.ts
2349
1756
  var import_discord11 = require("discord.js");
1757
+ var import_utils14 = require("@spatulox/utils");
2350
1758
  var NewsChannelManager = class extends GuildChannelManager {
2351
1759
  static async findInGuild(guildId, channelId) {
2352
1760
  const channel = await super.findInGuild(guildId, channelId);
@@ -2359,7 +1767,7 @@ var NewsChannelManager = class extends GuildChannelManager {
2359
1767
  static findAll(guildId) {
2360
1768
  const guild = Bot.client.guilds.cache.get(guildId);
2361
1769
  if (!guild) {
2362
- Log.warn(`Guild ${guildId} not found`);
1770
+ import_utils14.Log.warn(`Guild ${guildId} not found`);
2363
1771
  return [];
2364
1772
  }
2365
1773
  return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord11.NewsChannel);
@@ -2375,6 +1783,7 @@ var NewsChannelManager = class extends GuildChannelManager {
2375
1783
 
2376
1784
  // src/manager/guild/ChannelManager/StageChannelManager.ts
2377
1785
  var import_discord12 = require("discord.js");
1786
+ var import_utils15 = require("@spatulox/utils");
2378
1787
  var StageChannelManager = class extends GuildChannelManager {
2379
1788
  static async findInGuild(guildId, channelId) {
2380
1789
  const channel = await super.findInGuild(guildId, channelId);
@@ -2387,7 +1796,7 @@ var StageChannelManager = class extends GuildChannelManager {
2387
1796
  static findAll(guildId) {
2388
1797
  const guild = Bot.client.guilds.cache.get(guildId);
2389
1798
  if (!guild) {
2390
- Log.warn(`Guild ${guildId} not found`);
1799
+ import_utils15.Log.warn(`Guild ${guildId} not found`);
2391
1800
  return [];
2392
1801
  }
2393
1802
  return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord12.StageChannel);
@@ -2444,6 +1853,7 @@ var ThreadChannelManager = class {
2444
1853
 
2445
1854
  // src/manager/guild/ChannelManager/GuildVoiceChannelManager.ts
2446
1855
  var import_discord13 = require("discord.js");
1856
+ var import_utils16 = require("@spatulox/utils");
2447
1857
  var GuildVoiceChannelManager = class extends GuildChannelManager {
2448
1858
  static async findInGuild(guildId, channelId) {
2449
1859
  const channel = await super.findInGuild(guildId, channelId);
@@ -2456,7 +1866,7 @@ var GuildVoiceChannelManager = class extends GuildChannelManager {
2456
1866
  static findAll(guildId) {
2457
1867
  const guild = Bot.client.guilds.cache.get(guildId);
2458
1868
  if (!guild) {
2459
- Log.warn(`Guild ${guildId} not found`);
1869
+ import_utils16.Log.warn(`Guild ${guildId} not found`);
2460
1870
  return [];
2461
1871
  }
2462
1872
  return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord13.VoiceChannel);
@@ -2482,6 +1892,7 @@ var GuildChannelList = class {
2482
1892
  };
2483
1893
 
2484
1894
  // src/manager/guild/InviteManager.ts
1895
+ var import_utils17 = require("@spatulox/utils");
2485
1896
  var InviteManager = class {
2486
1897
  /**
2487
1898
  * Create an invite for a channel
@@ -2500,10 +1911,10 @@ var InviteManager = class {
2500
1911
  reason: options.reason
2501
1912
  };
2502
1913
  const invite = await guild.invites.create(channelId, inviteOptions);
2503
- Log.info(`Created invite ${invite.code} for channel ${channelId}`);
1914
+ import_utils17.Log.info(`Created invite ${invite.code} for channel ${channelId}`);
2504
1915
  return invite;
2505
1916
  } catch (error) {
2506
- Log.error(`Failed to create invite for channel ${channelId}: ${error}`);
1917
+ import_utils17.Log.error(`Failed to create invite for channel ${channelId}: ${error}`);
2507
1918
  throw error;
2508
1919
  }
2509
1920
  }
@@ -2513,10 +1924,10 @@ var InviteManager = class {
2513
1924
  static async delete(invite) {
2514
1925
  try {
2515
1926
  await invite.delete();
2516
- Log.info(`Deleted invite ${invite.code} from guild ${invite.guild?.id}`);
1927
+ import_utils17.Log.info(`Deleted invite ${invite.code} from guild ${invite.guild?.id}`);
2517
1928
  return true;
2518
1929
  } catch (error) {
2519
- Log.error(`Failed to delete invite ${invite.code}: ${error}`);
1930
+ import_utils17.Log.error(`Failed to delete invite ${invite.code}: ${error}`);
2520
1931
  return false;
2521
1932
  }
2522
1933
  }
@@ -2531,10 +1942,10 @@ var InviteManager = class {
2531
1942
  }
2532
1943
  const invites = await guild.invites.fetch();
2533
1944
  const inviteList = Array.from(invites.values());
2534
- Log.info(`Fetched ${inviteList.length} invites for guild ${guildId}`);
1945
+ import_utils17.Log.info(`Fetched ${inviteList.length} invites for guild ${guildId}`);
2535
1946
  return inviteList;
2536
1947
  } catch (error) {
2537
- Log.error(`Failed to fetch invites for guild ${guildId}: ${error}`);
1948
+ import_utils17.Log.error(`Failed to fetch invites for guild ${guildId}: ${error}`);
2538
1949
  throw error;
2539
1950
  }
2540
1951
  }
@@ -2555,7 +1966,7 @@ var GuildManager = class {
2555
1966
  if (cached) return cached;
2556
1967
  return await Bot.client.guilds.fetch(guild_id);
2557
1968
  } catch (error) {
2558
- Log.error(`GuildManager: Guild ${guild_id} : ${error} `);
1969
+ import_utils18.Log.error(`GuildManager: Guild ${guild_id} : ${error} `);
2559
1970
  return null;
2560
1971
  }
2561
1972
  }
@@ -2566,7 +1977,7 @@ var GuildManager = class {
2566
1977
  try {
2567
1978
  return await GuildChannelManager.findInGuild(guildId, channelId);
2568
1979
  } catch (error) {
2569
- Log.error(`Failed to fetch channel ${channelId}: ${error}`);
1980
+ import_utils18.Log.error(`Failed to fetch channel ${channelId}: ${error}`);
2570
1981
  return null;
2571
1982
  }
2572
1983
  }
@@ -2577,7 +1988,7 @@ var GuildManager = class {
2577
1988
  try {
2578
1989
  return await this.user.findInGuild(guildId, guildId);
2579
1990
  } catch (error) {
2580
- Log.error(`Failed to fetch member ${memberId} in guild ${guildId}: ${error}`);
1991
+ import_utils18.Log.error(`Failed to fetch member ${memberId} in guild ${guildId}: ${error}`);
2581
1992
  return null;
2582
1993
  }
2583
1994
  }
@@ -2594,7 +2005,7 @@ var GuildManager = class {
2594
2005
  /**
2595
2006
  * Fetch all members with retry (heavy operation)
2596
2007
  */
2597
- static async fetchAllMembers(guildId, MAX_ATTEMPTS = 3, RETRY_DELAY = Time.minute.MIN_05.toMilliseconds()) {
2008
+ static async fetchAllMembers(guildId, MAX_ATTEMPTS = 3, RETRY_DELAY = import_utils19.Time.minute.MIN_05.toMilliseconds()) {
2598
2009
  let guild;
2599
2010
  if (guildId instanceof import_discord14.Guild) {
2600
2011
  guild = guildId;
@@ -2605,10 +2016,10 @@ var GuildManager = class {
2605
2016
  }
2606
2017
  for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
2607
2018
  try {
2608
- Log.info(`UserManager: Fetching ${guild.name} members (attempt ${attempt})`);
2019
+ import_utils18.Log.info(`UserManager: Fetching ${guild.name} members (attempt ${attempt})`);
2609
2020
  return await guild.members.fetch();
2610
2021
  } catch (error) {
2611
- Log.error(`UserManager: Fetch failed (attempt ${attempt}): ${error}`);
2022
+ import_utils18.Log.error(`UserManager: Fetch failed (attempt ${attempt}): ${error}`);
2612
2023
  if (attempt < MAX_ATTEMPTS) {
2613
2024
  await new Promise((r) => setTimeout(r, RETRY_DELAY));
2614
2025
  }
@@ -2625,7 +2036,7 @@ var GuildManager = class {
2625
2036
  const bans = await guild.bans.fetch({ limit });
2626
2037
  return Array.from(bans.values());
2627
2038
  } catch (error) {
2628
- Log.error(`Failed to list bans in guild ${guildId}: ${error}`);
2039
+ import_utils18.Log.error(`Failed to list bans in guild ${guildId}: ${error}`);
2629
2040
  throw error;
2630
2041
  }
2631
2042
  }
@@ -2660,26 +2071,27 @@ var GuildManager = class {
2660
2071
  }
2661
2072
  try {
2662
2073
  await member.voice.setChannel(toChannel);
2663
- Log.info(`Moved member ${memberId} from ${fromChannelId} to ${toChannelId}`);
2074
+ import_utils18.Log.info(`Moved member ${memberId} from ${fromChannelId} to ${toChannelId}`);
2664
2075
  } catch (error) {
2665
- Log.error(`Failed to move member ${memberId} from ${fromChannelId} to ${toChannelId}: ${error}`);
2076
+ import_utils18.Log.error(`Failed to move member ${memberId} from ${fromChannelId} to ${toChannelId}: ${error}`);
2666
2077
  throw error;
2667
2078
  }
2668
2079
  return true;
2669
2080
  } catch (e) {
2670
- Log.error(`Failed to move member ${e}`);
2081
+ import_utils18.Log.error(`Failed to move member ${e}`);
2671
2082
  return false;
2672
2083
  }
2673
2084
  }
2674
2085
  };
2675
2086
 
2676
2087
  // src/manager/direct/UserManager.ts
2088
+ var import_utils20 = require("@spatulox/utils");
2677
2089
  var UserManager = class extends BasicUserManager {
2678
2090
  static async find(userId) {
2679
2091
  const cached = Bot.client.users.cache.get(userId);
2680
2092
  if (cached) return cached;
2681
2093
  const user = await Bot.client.users.fetch(userId).catch(() => null);
2682
- if (!user) Log.error(`UserManager: User ${userId} not found`);
2094
+ if (!user) import_utils20.Log.error(`UserManager: User ${userId} not found`);
2683
2095
  return user;
2684
2096
  }
2685
2097
  };
@@ -2916,7 +2328,7 @@ var ComponentManager = class {
2916
2328
  options.value && container.addTextDisplayComponents(new import_discord16.TextDisplayBuilder().setContent(options.value));
2917
2329
  }
2918
2330
  static field(container, field) {
2919
- const hasText = "name" in field && "value" in field && field.name && field.value;
2331
+ const hasText = ("name" in field || "value" in field) && (field.name || field.value);
2920
2332
  if ("button" in field && Array.isArray(field.button) && field.button.length > 0) {
2921
2333
  const actionRow = new import_discord16.ActionRowBuilder().addComponents(field.button);
2922
2334
  if (hasText) this.fieldAddText(container, { name: field.name, value: field.value });
@@ -3116,46 +2528,10 @@ var ButtonManager = class _ButtonManager {
3116
2528
  }
3117
2529
  };
3118
2530
 
3119
- // src/utils/SimpleMutex.ts
3120
- var SimpleMutex = class {
3121
- _locked;
3122
- // Indique si le mutex est verrouillé
3123
- queue;
3124
- // File d'attente des fonctions de résolution
3125
- constructor() {
3126
- this._locked = false;
3127
- this.queue = [];
3128
- }
3129
- /**
3130
- * Verrouille le mutex. Si le mutex est déjà verrouillé, la méthode retourne une promesse qui sera résolue une fois que le mutex sera disponible.
3131
- * @returns Une promesse résolue lorsque le mutex est verrouillé.
3132
- */
3133
- async lock() {
3134
- if (this._locked) {
3135
- return new Promise((resolve2) => {
3136
- this.queue.push(resolve2);
3137
- });
3138
- }
3139
- this._locked = true;
3140
- return Promise.resolve();
3141
- }
3142
- /**
3143
- * Déverrouille le mutex. Si une file d'attente existe, débloque le prochain élément dans la file.
3144
- */
3145
- unlock() {
3146
- if (this.queue.length > 0) {
3147
- const nextResolve = this.queue.shift();
3148
- if (nextResolve) {
3149
- nextResolve();
3150
- }
3151
- return;
3152
- }
3153
- this._locked = false;
3154
- }
3155
- get locked() {
3156
- return this._locked;
3157
- }
3158
- };
2531
+ // src/index.ts
2532
+ var import_utils23 = require("@spatulox/utils");
2533
+ var import_utils24 = require("@spatulox/utils");
2534
+ var import_utils25 = require("@spatulox/utils");
3159
2535
 
3160
2536
  // src/constants/DiscordRegex.ts
3161
2537
  var DiscordRegex = class {