@spatulox/simplediscordbot 2.0.3 → 2.1.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/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Changelog
2
2
  Date format : dd/mm/yyy
3
3
 
4
+ ### 15/04/2026 - 2.1.0
5
+ - Add a CacheManager for simple persisting data
6
+ - Add QoL method to FileManager (fileExist(), deleteFile())
7
+ - Fix :
8
+ - SimpleDiscordBotInfo.version showing license instead of version
9
+ - FileManager should be able to create hidden folder
10
+
11
+ ### 13/04/2026 - 2.0.3
12
+ - Fix : WebhookManager can now send webhooks in threads
13
+
4
14
  ### 08/04/2026 - 2.0.1
5
15
  - Fix the README.md to match the new BotLog system
6
16
 
package/dist/index.d.mts CHANGED
@@ -160,6 +160,12 @@ declare const BotEnv: {
160
160
  };
161
161
 
162
162
  declare class FileManager {
163
+ /**
164
+ * Check if a file exist
165
+ * @param filePath File path with file name
166
+ * @returns true si le fichier existe, false sinon
167
+ */
168
+ static fileExists(filePath: string): Promise<boolean>;
163
169
  /**
164
170
  * Reads a JSON file synchronously.
165
171
  * @param filePath Full path to the JSON file
@@ -194,6 +200,12 @@ declare class FileManager {
194
200
  * @returns true on success, false on failure
195
201
  */
196
202
  static writeJsonFile(directoryPath: string, filename: string, data: any, sendErrorToErrorChannel?: boolean): Promise<boolean>;
203
+ /**
204
+ * Delete a file
205
+ * @param filePath Full file path
206
+ * @returns true si supprimé avec succès, false sinon
207
+ */
208
+ static deleteFile(filePath: string): Promise<boolean>;
197
209
  }
198
210
 
199
211
  declare class EmbedManager {
package/dist/index.d.ts CHANGED
@@ -160,6 +160,12 @@ declare const BotEnv: {
160
160
  };
161
161
 
162
162
  declare class FileManager {
163
+ /**
164
+ * Check if a file exist
165
+ * @param filePath File path with file name
166
+ * @returns true si le fichier existe, false sinon
167
+ */
168
+ static fileExists(filePath: string): Promise<boolean>;
163
169
  /**
164
170
  * Reads a JSON file synchronously.
165
171
  * @param filePath Full path to the JSON file
@@ -194,6 +200,12 @@ declare class FileManager {
194
200
  * @returns true on success, false on failure
195
201
  */
196
202
  static writeJsonFile(directoryPath: string, filename: string, data: any, sendErrorToErrorChannel?: boolean): Promise<boolean>;
203
+ /**
204
+ * Delete a file
205
+ * @param filePath Full file path
206
+ * @returns true si supprimé avec succès, false sinon
207
+ */
208
+ static deleteFile(filePath: string): Promise<boolean>;
197
209
  }
198
210
 
199
211
  declare class EmbedManager {
package/dist/index.js CHANGED
@@ -5546,7 +5546,7 @@ var _BotLog = class _BotLog {
5546
5546
  * Send INFO log - TEXT or EMBED ! Respecte config.log.info
5547
5547
  */
5548
5548
  static async info(content) {
5549
- const logConfig = Bot.config.log;
5549
+ const logConfig = Bot.config?.log;
5550
5550
  if (!logConfig || logConfig.info.console) {
5551
5551
  if (typeof content == "string") {
5552
5552
  Log.info(content);
@@ -5667,7 +5667,7 @@ var EmbedManager = class {
5667
5667
  if (colorC !== "transparent" /* transparent */) {
5668
5668
  embed.setColor(colorC);
5669
5669
  }
5670
- if (Bot.config.botName) {
5670
+ if (Bot.config?.botName) {
5671
5671
  const footer = {
5672
5672
  text: Bot.config.botName
5673
5673
  };
@@ -14326,6 +14326,68 @@ var BotInteraction = class {
14326
14326
  }
14327
14327
  };
14328
14328
 
14329
+ // package.json
14330
+ var package_default = {
14331
+ name: "@spatulox/simplediscordbot",
14332
+ version: "2.0.3",
14333
+ author: "Spatulox",
14334
+ description: "Simple discord bot framework to set up a bot under 30 secondes",
14335
+ exports: {
14336
+ types: "./dist/index.d.ts",
14337
+ import: "./dist/index.js",
14338
+ require: "./dist/index.js"
14339
+ },
14340
+ types: "./dist/index.d.ts",
14341
+ scripts: {
14342
+ "type-check": "tsc --noEmit",
14343
+ build: "npm run type-check && rm -rf ./dist/ && tsup",
14344
+ dev: "npm run type-check && tsx watch src/test/index.ts",
14345
+ patch: "npm run build && npm version patch",
14346
+ minor: "npm run build && npm version minor",
14347
+ major: "npm run build && npm version major",
14348
+ "pub:patch": "npm run patch && npm publish --access public",
14349
+ "pub:minor": "npm run minor && npm publish --access public",
14350
+ "pub:major": "npm run major && npm publish --access public"
14351
+ },
14352
+ license: "MIT",
14353
+ dependencies: {
14354
+ "@spatulox/discord-interaction-manager": "^2.0.6"
14355
+ },
14356
+ peerDependencies: {
14357
+ "discord.js": "^14.26.0"
14358
+ },
14359
+ devDependencies: {
14360
+ "@types/node": "^22.14.0",
14361
+ "@types/node-schedule": "^2.1.7",
14362
+ "discord.js": "^14.26.0",
14363
+ dotenv: "^17.2.4",
14364
+ tsup: "^8.5.1",
14365
+ tsx: "^4.20.3",
14366
+ typescript: "^5.9.3"
14367
+ },
14368
+ keywords: [
14369
+ "discord",
14370
+ "framework",
14371
+ "bot",
14372
+ "client",
14373
+ "discordjs",
14374
+ "discord.js",
14375
+ "node"
14376
+ ],
14377
+ bugs: {
14378
+ url: "https://github.com/Spatulox/SimpleDiscordBot/issues"
14379
+ }
14380
+ };
14381
+
14382
+ // src/SimpleDiscordBotInfo.ts
14383
+ var SimpleDiscordBotInfo = {
14384
+ name: package_default.name,
14385
+ version: package_default.version,
14386
+ author: package_default.author,
14387
+ description: package_default.description,
14388
+ license: package_default.license
14389
+ };
14390
+
14329
14391
  // src/core/Bot.ts
14330
14392
  var _Bot = class _Bot {
14331
14393
  get config() {
@@ -14348,6 +14410,7 @@ var _Bot = class _Bot {
14348
14410
  _Bot._client = client;
14349
14411
  (async () => {
14350
14412
  Log.info(`Using discord.js version: ${import_discord6.version}`);
14413
+ Log.info(`Using simplediscordbot version: ${SimpleDiscordBotInfo.version}`);
14351
14414
  Log.info("Trying to connect to Discord Servers");
14352
14415
  await InternetChecker.checkConnection(3);
14353
14416
  await this.login();
@@ -14420,6 +14483,19 @@ var Bot = _Bot;
14420
14483
  var import_path = __toESM(require("path"));
14421
14484
  var import_promises = __toESM(require("fs/promises"));
14422
14485
  var FileManager = class {
14486
+ /**
14487
+ * Check if a file exist
14488
+ * @param filePath File path with file name
14489
+ * @returns true si le fichier existe, false sinon
14490
+ */
14491
+ static async fileExists(filePath) {
14492
+ try {
14493
+ await import_promises.default.access(filePath);
14494
+ return true;
14495
+ } catch {
14496
+ return false;
14497
+ }
14498
+ }
14423
14499
  /**
14424
14500
  * Reads a JSON file synchronously.
14425
14501
  * @param filePath Full path to the JSON file
@@ -14442,8 +14518,7 @@ var FileManager = class {
14442
14518
  static async listDirectories(directoryPath) {
14443
14519
  try {
14444
14520
  const files = await import_promises.default.readdir(directoryPath, { withFileTypes: true });
14445
- const directories = files.filter((file) => file.isDirectory()).map((dir) => dir.name);
14446
- return directories;
14521
+ return files.filter((file) => file.isDirectory()).map((dir) => dir.name);
14447
14522
  } catch (error) {
14448
14523
  Log.error(`Failed to read directory ${directoryPath}: ${error}`);
14449
14524
  return false;
@@ -14500,16 +14575,7 @@ var FileManager = class {
14500
14575
  return false;
14501
14576
  }
14502
14577
  try {
14503
- const directories = directoryPath.split(import_path.default.sep).filter(Boolean);
14504
- let currentPath = "";
14505
- for (const dir of directories) {
14506
- currentPath = import_path.default.join(currentPath, dir);
14507
- try {
14508
- await import_promises.default.access(currentPath);
14509
- } catch {
14510
- await import_promises.default.mkdir(currentPath, { recursive: true });
14511
- }
14512
- }
14578
+ await import_promises.default.mkdir(directoryPath, { recursive: true });
14513
14579
  if (!filename || filename.trim() === "") {
14514
14580
  Log.error("Cannot write JSON file: empty filename");
14515
14581
  return false;
@@ -14530,6 +14596,25 @@ var FileManager = class {
14530
14596
  return false;
14531
14597
  }
14532
14598
  }
14599
+ /**
14600
+ * Delete a file
14601
+ * @param filePath Full file path
14602
+ * @returns true si supprimé avec succès, false sinon
14603
+ */
14604
+ static async deleteFile(filePath) {
14605
+ try {
14606
+ if (!await this.fileExists(filePath)) {
14607
+ Log.warn(`File does not exist: ${filePath}`);
14608
+ return false;
14609
+ }
14610
+ await import_promises.default.unlink(filePath);
14611
+ Log.info(`Successfully deleted file: ${filePath}`);
14612
+ return true;
14613
+ } catch (error) {
14614
+ Log.error(`Failed to delete file ${filePath}: ${error}`);
14615
+ return false;
14616
+ }
14617
+ }
14533
14618
  };
14534
14619
 
14535
14620
  // src/manager/messages/WebhookManager.ts
@@ -16148,68 +16233,6 @@ var SimpleMutex = class {
16148
16233
  return this._locked;
16149
16234
  }
16150
16235
  };
16151
-
16152
- // package.json
16153
- var package_default = {
16154
- name: "@spatulox/simplediscordbot",
16155
- version: "2.0.2",
16156
- author: "Spatulox",
16157
- description: "Simple discord bot framework to set up a bot under 30 secondes",
16158
- exports: {
16159
- types: "./dist/index.d.ts",
16160
- import: "./dist/index.js",
16161
- require: "./dist/index.js"
16162
- },
16163
- types: "./dist/index.d.ts",
16164
- scripts: {
16165
- "type-check": "tsc --noEmit",
16166
- build: "npm run type-check && rm -rf ./dist/ && tsup",
16167
- dev: "npm run type-check && tsx watch src/test/index.ts",
16168
- patch: "npm run build && npm version patch",
16169
- minor: "npm run build && npm version minor",
16170
- major: "npm run build && npm version major",
16171
- "pub:patch": "npm run patch && npm publish --access public",
16172
- "pub:minor": "npm run minor && npm publish --access public",
16173
- "pub:major": "npm run major && npm publish --access public"
16174
- },
16175
- license: "MIT",
16176
- dependencies: {
16177
- "@spatulox/discord-interaction-manager": "^2.0.6"
16178
- },
16179
- peerDependencies: {
16180
- "discord.js": "^14.26.0"
16181
- },
16182
- devDependencies: {
16183
- "@types/node": "^22.14.0",
16184
- "@types/node-schedule": "^2.1.7",
16185
- "discord.js": "^14.26.0",
16186
- dotenv: "^17.2.4",
16187
- tsup: "^8.5.1",
16188
- tsx: "^4.20.3",
16189
- typescript: "^5.9.3"
16190
- },
16191
- keywords: [
16192
- "discord",
16193
- "framework",
16194
- "bot",
16195
- "client",
16196
- "discordjs",
16197
- "discord.js",
16198
- "node"
16199
- ],
16200
- bugs: {
16201
- url: "https://github.com/Spatulox/SimpleDiscordBot/issues"
16202
- }
16203
- };
16204
-
16205
- // src/SimpleDiscordBotInfo.ts
16206
- var SimpleDiscordBotInfo = {
16207
- name: package_default.name,
16208
- version: package_default.license,
16209
- author: package_default.author,
16210
- description: package_default.description,
16211
- license: package_default.license
16212
- };
16213
16236
  // Annotate the CommonJS export names for ESM import in node:
16214
16237
  0 && (module.exports = {
16215
16238
  Bot,
package/dist/index.mjs CHANGED
@@ -5529,7 +5529,7 @@ var _BotLog = class _BotLog {
5529
5529
  * Send INFO log - TEXT or EMBED ! Respecte config.log.info
5530
5530
  */
5531
5531
  static async info(content) {
5532
- const logConfig = Bot.config.log;
5532
+ const logConfig = Bot.config?.log;
5533
5533
  if (!logConfig || logConfig.info.console) {
5534
5534
  if (typeof content == "string") {
5535
5535
  Log.info(content);
@@ -5653,7 +5653,7 @@ var EmbedManager = class {
5653
5653
  if (colorC !== "transparent" /* transparent */) {
5654
5654
  embed.setColor(colorC);
5655
5655
  }
5656
- if (Bot.config.botName) {
5656
+ if (Bot.config?.botName) {
5657
5657
  const footer = {
5658
5658
  text: Bot.config.botName
5659
5659
  };
@@ -14320,6 +14320,68 @@ var BotInteraction = class {
14320
14320
  }
14321
14321
  };
14322
14322
 
14323
+ // package.json
14324
+ var package_default = {
14325
+ name: "@spatulox/simplediscordbot",
14326
+ version: "2.0.3",
14327
+ author: "Spatulox",
14328
+ description: "Simple discord bot framework to set up a bot under 30 secondes",
14329
+ exports: {
14330
+ types: "./dist/index.d.ts",
14331
+ import: "./dist/index.js",
14332
+ require: "./dist/index.js"
14333
+ },
14334
+ types: "./dist/index.d.ts",
14335
+ scripts: {
14336
+ "type-check": "tsc --noEmit",
14337
+ build: "npm run type-check && rm -rf ./dist/ && tsup",
14338
+ dev: "npm run type-check && tsx watch src/test/index.ts",
14339
+ patch: "npm run build && npm version patch",
14340
+ minor: "npm run build && npm version minor",
14341
+ major: "npm run build && npm version major",
14342
+ "pub:patch": "npm run patch && npm publish --access public",
14343
+ "pub:minor": "npm run minor && npm publish --access public",
14344
+ "pub:major": "npm run major && npm publish --access public"
14345
+ },
14346
+ license: "MIT",
14347
+ dependencies: {
14348
+ "@spatulox/discord-interaction-manager": "^2.0.6"
14349
+ },
14350
+ peerDependencies: {
14351
+ "discord.js": "^14.26.0"
14352
+ },
14353
+ devDependencies: {
14354
+ "@types/node": "^22.14.0",
14355
+ "@types/node-schedule": "^2.1.7",
14356
+ "discord.js": "^14.26.0",
14357
+ dotenv: "^17.2.4",
14358
+ tsup: "^8.5.1",
14359
+ tsx: "^4.20.3",
14360
+ typescript: "^5.9.3"
14361
+ },
14362
+ keywords: [
14363
+ "discord",
14364
+ "framework",
14365
+ "bot",
14366
+ "client",
14367
+ "discordjs",
14368
+ "discord.js",
14369
+ "node"
14370
+ ],
14371
+ bugs: {
14372
+ url: "https://github.com/Spatulox/SimpleDiscordBot/issues"
14373
+ }
14374
+ };
14375
+
14376
+ // src/SimpleDiscordBotInfo.ts
14377
+ var SimpleDiscordBotInfo = {
14378
+ name: package_default.name,
14379
+ version: package_default.version,
14380
+ author: package_default.author,
14381
+ description: package_default.description,
14382
+ license: package_default.license
14383
+ };
14384
+
14323
14385
  // src/core/Bot.ts
14324
14386
  var _Bot = class _Bot {
14325
14387
  get config() {
@@ -14342,6 +14404,7 @@ var _Bot = class _Bot {
14342
14404
  _Bot._client = client;
14343
14405
  (async () => {
14344
14406
  Log.info(`Using discord.js version: ${version}`);
14407
+ Log.info(`Using simplediscordbot version: ${SimpleDiscordBotInfo.version}`);
14345
14408
  Log.info("Trying to connect to Discord Servers");
14346
14409
  await InternetChecker.checkConnection(3);
14347
14410
  await this.login();
@@ -14414,6 +14477,19 @@ var Bot = _Bot;
14414
14477
  import path from "path";
14415
14478
  import fs from "fs/promises";
14416
14479
  var FileManager = class {
14480
+ /**
14481
+ * Check if a file exist
14482
+ * @param filePath File path with file name
14483
+ * @returns true si le fichier existe, false sinon
14484
+ */
14485
+ static async fileExists(filePath) {
14486
+ try {
14487
+ await fs.access(filePath);
14488
+ return true;
14489
+ } catch {
14490
+ return false;
14491
+ }
14492
+ }
14417
14493
  /**
14418
14494
  * Reads a JSON file synchronously.
14419
14495
  * @param filePath Full path to the JSON file
@@ -14436,8 +14512,7 @@ var FileManager = class {
14436
14512
  static async listDirectories(directoryPath) {
14437
14513
  try {
14438
14514
  const files = await fs.readdir(directoryPath, { withFileTypes: true });
14439
- const directories = files.filter((file) => file.isDirectory()).map((dir) => dir.name);
14440
- return directories;
14515
+ return files.filter((file) => file.isDirectory()).map((dir) => dir.name);
14441
14516
  } catch (error) {
14442
14517
  Log.error(`Failed to read directory ${directoryPath}: ${error}`);
14443
14518
  return false;
@@ -14494,16 +14569,7 @@ var FileManager = class {
14494
14569
  return false;
14495
14570
  }
14496
14571
  try {
14497
- const directories = directoryPath.split(path.sep).filter(Boolean);
14498
- let currentPath = "";
14499
- for (const dir of directories) {
14500
- currentPath = path.join(currentPath, dir);
14501
- try {
14502
- await fs.access(currentPath);
14503
- } catch {
14504
- await fs.mkdir(currentPath, { recursive: true });
14505
- }
14506
- }
14572
+ await fs.mkdir(directoryPath, { recursive: true });
14507
14573
  if (!filename || filename.trim() === "") {
14508
14574
  Log.error("Cannot write JSON file: empty filename");
14509
14575
  return false;
@@ -14524,6 +14590,25 @@ var FileManager = class {
14524
14590
  return false;
14525
14591
  }
14526
14592
  }
14593
+ /**
14594
+ * Delete a file
14595
+ * @param filePath Full file path
14596
+ * @returns true si supprimé avec succès, false sinon
14597
+ */
14598
+ static async deleteFile(filePath) {
14599
+ try {
14600
+ if (!await this.fileExists(filePath)) {
14601
+ Log.warn(`File does not exist: ${filePath}`);
14602
+ return false;
14603
+ }
14604
+ await fs.unlink(filePath);
14605
+ Log.info(`Successfully deleted file: ${filePath}`);
14606
+ return true;
14607
+ } catch (error) {
14608
+ Log.error(`Failed to delete file ${filePath}: ${error}`);
14609
+ return false;
14610
+ }
14611
+ }
14527
14612
  };
14528
14613
 
14529
14614
  // src/manager/messages/WebhookManager.ts
@@ -16170,68 +16255,6 @@ var SimpleMutex = class {
16170
16255
  return this._locked;
16171
16256
  }
16172
16257
  };
16173
-
16174
- // package.json
16175
- var package_default = {
16176
- name: "@spatulox/simplediscordbot",
16177
- version: "2.0.2",
16178
- author: "Spatulox",
16179
- description: "Simple discord bot framework to set up a bot under 30 secondes",
16180
- exports: {
16181
- types: "./dist/index.d.ts",
16182
- import: "./dist/index.js",
16183
- require: "./dist/index.js"
16184
- },
16185
- types: "./dist/index.d.ts",
16186
- scripts: {
16187
- "type-check": "tsc --noEmit",
16188
- build: "npm run type-check && rm -rf ./dist/ && tsup",
16189
- dev: "npm run type-check && tsx watch src/test/index.ts",
16190
- patch: "npm run build && npm version patch",
16191
- minor: "npm run build && npm version minor",
16192
- major: "npm run build && npm version major",
16193
- "pub:patch": "npm run patch && npm publish --access public",
16194
- "pub:minor": "npm run minor && npm publish --access public",
16195
- "pub:major": "npm run major && npm publish --access public"
16196
- },
16197
- license: "MIT",
16198
- dependencies: {
16199
- "@spatulox/discord-interaction-manager": "^2.0.6"
16200
- },
16201
- peerDependencies: {
16202
- "discord.js": "^14.26.0"
16203
- },
16204
- devDependencies: {
16205
- "@types/node": "^22.14.0",
16206
- "@types/node-schedule": "^2.1.7",
16207
- "discord.js": "^14.26.0",
16208
- dotenv: "^17.2.4",
16209
- tsup: "^8.5.1",
16210
- tsx: "^4.20.3",
16211
- typescript: "^5.9.3"
16212
- },
16213
- keywords: [
16214
- "discord",
16215
- "framework",
16216
- "bot",
16217
- "client",
16218
- "discordjs",
16219
- "discord.js",
16220
- "node"
16221
- ],
16222
- bugs: {
16223
- url: "https://github.com/Spatulox/SimpleDiscordBot/issues"
16224
- }
16225
- };
16226
-
16227
- // src/SimpleDiscordBotInfo.ts
16228
- var SimpleDiscordBotInfo = {
16229
- name: package_default.name,
16230
- version: package_default.license,
16231
- author: package_default.author,
16232
- description: package_default.description,
16233
- license: package_default.license
16234
- };
16235
16258
  export {
16236
16259
  Bot,
16237
16260
  BotEnv,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spatulox/simplediscordbot",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "author": "Spatulox",
5
5
  "description": "Simple discord bot framework to set up a bot under 30 secondes",
6
6
  "exports": {