@spatulox/simplediscordbot 1.0.22 → 1.0.24

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 (115) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -1
  4. package/package.json +7 -3
  5. package/dist/bot/Bot.d.ts +0 -35
  6. package/dist/bot/Bot.d.ts.map +0 -1
  7. package/dist/bot/Bot.js +0 -92
  8. package/dist/bot/BotEnv.d.ts +0 -6
  9. package/dist/bot/BotEnv.d.ts.map +0 -1
  10. package/dist/bot/BotEnv.js +0 -24
  11. package/dist/bot/BotInteraction.d.ts +0 -21
  12. package/dist/bot/BotInteraction.d.ts.map +0 -1
  13. package/dist/bot/BotInteraction.js +0 -74
  14. package/dist/bot/BotLog.d.ts +0 -52
  15. package/dist/bot/BotLog.d.ts.map +0 -1
  16. package/dist/bot/BotLog.js +0 -134
  17. package/dist/bot/BotMessage.d.ts +0 -20
  18. package/dist/bot/BotMessage.d.ts.map +0 -1
  19. package/dist/bot/BotMessage.js +0 -110
  20. package/dist/manager/FileManager.d.ts +0 -37
  21. package/dist/manager/FileManager.d.ts.map +0 -1
  22. package/dist/manager/FileManager.js +0 -136
  23. package/dist/manager/builder/SendableComponentBuilder.d.ts +0 -13
  24. package/dist/manager/builder/SendableComponentBuilder.d.ts.map +0 -1
  25. package/dist/manager/builder/SendableComponentBuilder.js +0 -62
  26. package/dist/manager/direct/BasicUserManager.d.ts +0 -28
  27. package/dist/manager/direct/BasicUserManager.d.ts.map +0 -1
  28. package/dist/manager/direct/BasicUserManager.js +0 -81
  29. package/dist/manager/direct/UserManager.d.ts +0 -6
  30. package/dist/manager/direct/UserManager.d.ts.map +0 -1
  31. package/dist/manager/direct/UserManager.js +0 -18
  32. package/dist/manager/guild/ChannelManager/ForumChannelManager.d.ts +0 -9
  33. package/dist/manager/guild/ChannelManager/ForumChannelManager.d.ts.map +0 -1
  34. package/dist/manager/guild/ChannelManager/ForumChannelManager.js +0 -33
  35. package/dist/manager/guild/ChannelManager/GuildChannelList.d.ts +0 -17
  36. package/dist/manager/guild/ChannelManager/GuildChannelList.d.ts.map +0 -1
  37. package/dist/manager/guild/ChannelManager/GuildChannelList.js +0 -20
  38. package/dist/manager/guild/ChannelManager/GuildChannelManager.d.ts +0 -18
  39. package/dist/manager/guild/ChannelManager/GuildChannelManager.d.ts.map +0 -1
  40. package/dist/manager/guild/ChannelManager/GuildChannelManager.js +0 -91
  41. package/dist/manager/guild/ChannelManager/GuildMessageManager.d.ts +0 -23
  42. package/dist/manager/guild/ChannelManager/GuildMessageManager.d.ts.map +0 -1
  43. package/dist/manager/guild/ChannelManager/GuildMessageManager.js +0 -93
  44. package/dist/manager/guild/ChannelManager/GuildTextChannelManager.d.ts +0 -9
  45. package/dist/manager/guild/ChannelManager/GuildTextChannelManager.d.ts.map +0 -1
  46. package/dist/manager/guild/ChannelManager/GuildTextChannelManager.js +0 -33
  47. package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.d.ts +0 -9
  48. package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.d.ts.map +0 -1
  49. package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.js +0 -33
  50. package/dist/manager/guild/ChannelManager/NewsChannelManager.d.ts +0 -9
  51. package/dist/manager/guild/ChannelManager/NewsChannelManager.d.ts.map +0 -1
  52. package/dist/manager/guild/ChannelManager/NewsChannelManager.js +0 -33
  53. package/dist/manager/guild/ChannelManager/StageChannelManager.d.ts +0 -9
  54. package/dist/manager/guild/ChannelManager/StageChannelManager.d.ts.map +0 -1
  55. package/dist/manager/guild/ChannelManager/StageChannelManager.js +0 -33
  56. package/dist/manager/guild/ChannelManager/ThreadChannelManager.d.ts +0 -13
  57. package/dist/manager/guild/ChannelManager/ThreadChannelManager.d.ts.map +0 -1
  58. package/dist/manager/guild/ChannelManager/ThreadChannelManager.js +0 -49
  59. package/dist/manager/guild/GuildManager.d.ts +0 -32
  60. package/dist/manager/guild/GuildManager.d.ts.map +0 -1
  61. package/dist/manager/guild/GuildManager.js +0 -144
  62. package/dist/manager/guild/GuildUserManager.d.ts +0 -49
  63. package/dist/manager/guild/GuildUserManager.d.ts.map +0 -1
  64. package/dist/manager/guild/GuildUserManager.js +0 -251
  65. package/dist/manager/guild/InviteManager.d.ts +0 -21
  66. package/dist/manager/guild/InviteManager.d.ts.map +0 -1
  67. package/dist/manager/guild/InviteManager.js +0 -68
  68. package/dist/manager/guild/InviteManager_old.d.ts +0 -24
  69. package/dist/manager/guild/InviteManager_old.d.ts.map +0 -1
  70. package/dist/manager/guild/InviteManager_old.js +0 -89
  71. package/dist/manager/guild/RoleManager.d.ts +0 -24
  72. package/dist/manager/guild/RoleManager.d.ts.map +0 -1
  73. package/dist/manager/guild/RoleManager.js +0 -83
  74. package/dist/manager/interactions/ModalManager.d.ts +0 -23
  75. package/dist/manager/interactions/ModalManager.d.ts.map +0 -1
  76. package/dist/manager/interactions/ModalManager.js +0 -113
  77. package/dist/manager/interactions/SelectMenuManager.d.ts +0 -58
  78. package/dist/manager/interactions/SelectMenuManager.d.ts.map +0 -1
  79. package/dist/manager/interactions/SelectMenuManager.js +0 -123
  80. package/dist/manager/messages/EmbedManager.d.ts +0 -97
  81. package/dist/manager/messages/EmbedManager.d.ts.map +0 -1
  82. package/dist/manager/messages/EmbedManager.js +0 -161
  83. package/dist/manager/messages/ReactionManager.d.ts +0 -26
  84. package/dist/manager/messages/ReactionManager.d.ts.map +0 -1
  85. package/dist/manager/messages/ReactionManager.js +0 -99
  86. package/dist/manager/messages/WebhookManager.d.ts +0 -33
  87. package/dist/manager/messages/WebhookManager.d.ts.map +0 -1
  88. package/dist/manager/messages/WebhookManager.js +0 -108
  89. package/dist/test/client.d.ts +0 -3
  90. package/dist/test/client.d.ts.map +0 -1
  91. package/dist/test/client.js +0 -15
  92. package/dist/test/index.d.ts +0 -2
  93. package/dist/test/index.d.ts.map +0 -1
  94. package/dist/test/index.js +0 -31
  95. package/dist/test/randomActivityList.d.ts +0 -3
  96. package/dist/test/randomActivityList.d.ts.map +0 -1
  97. package/dist/test/randomActivityList.js +0 -9
  98. package/dist/type/FolderName.d.ts +0 -6
  99. package/dist/type/FolderName.d.ts.map +0 -1
  100. package/dist/type/FolderName.js +0 -9
  101. package/dist/utils/DiscordRegex.d.ts +0 -66
  102. package/dist/utils/DiscordRegex.d.ts.map +0 -1
  103. package/dist/utils/DiscordRegex.js +0 -117
  104. package/dist/utils/Log.d.ts +0 -9
  105. package/dist/utils/Log.d.ts.map +0 -1
  106. package/dist/utils/Log.js +0 -28
  107. package/dist/utils/SimpleMutex.d.ts +0 -16
  108. package/dist/utils/SimpleMutex.d.ts.map +0 -1
  109. package/dist/utils/SimpleMutex.js +0 -39
  110. package/dist/utils/network/InternetChecker.d.ts +0 -10
  111. package/dist/utils/network/InternetChecker.d.ts.map +0 -1
  112. package/dist/utils/network/InternetChecker.js +0 -54
  113. package/dist/utils/times/UnitTime.d.ts +0 -187
  114. package/dist/utils/times/UnitTime.d.ts.map +0 -1
  115. package/dist/utils/times/UnitTime.js +0 -85
package/dist/index.d.ts CHANGED
@@ -13,4 +13,5 @@ export { Log } from "./utils/Log";
13
13
  export { SimpleMutex } from "./utils/SimpleMutex";
14
14
  export { DiscordRegex } from "./utils/DiscordRegex";
15
15
  export type { BotConfig, RandomBotActivity } from './bot/Bot';
16
+ export { SimpleDiscordBotInfo } from "./SimpleDiscordBotInfo";
16
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAIpC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAG7E,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAIpC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAG7E,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DiscordRegex = exports.SimpleMutex = exports.Log = exports.Time = exports.SelectMenuManager = exports.ModalManager = exports.UserManager = exports.GuildManager = exports.ReactionManager = exports.WebhookManager = exports.EmbedColor = exports.EmbedManager = exports.FileManager = exports.BotEnv = exports.Bot = void 0;
3
+ exports.SimpleDiscordBotInfo = exports.DiscordRegex = exports.SimpleMutex = exports.Log = exports.Time = exports.SelectMenuManager = exports.ModalManager = exports.UserManager = exports.GuildManager = exports.ReactionManager = exports.WebhookManager = exports.EmbedColor = exports.EmbedManager = exports.FileManager = exports.BotEnv = exports.Bot = void 0;
4
4
  var Bot_1 = require("./bot/Bot");
5
5
  Object.defineProperty(exports, "Bot", { enumerable: true, get: function () { return Bot_1.Bot; } });
6
6
  var BotEnv_1 = require("./bot/BotEnv");
@@ -33,3 +33,5 @@ var SimpleMutex_1 = require("./utils/SimpleMutex");
33
33
  Object.defineProperty(exports, "SimpleMutex", { enumerable: true, get: function () { return SimpleMutex_1.SimpleMutex; } });
34
34
  var DiscordRegex_1 = require("./utils/DiscordRegex");
35
35
  Object.defineProperty(exports, "DiscordRegex", { enumerable: true, get: function () { return DiscordRegex_1.DiscordRegex; } });
36
+ var SimpleDiscordBotInfo_1 = require("./SimpleDiscordBotInfo");
37
+ Object.defineProperty(exports, "SimpleDiscordBotInfo", { enumerable: true, get: function () { return SimpleDiscordBotInfo_1.SimpleDiscordBotInfo; } });
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@spatulox/simplediscordbot",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "author": "Spatulox",
5
5
  "description": "Simple discord bot framework to set up a bot under 30 secondes",
6
- "exports": "./dist/index.js",
6
+ "exports": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js",
9
+ "require": "./dist/index.js"
10
+ },
7
11
  "types": "./dist/index.d.ts",
8
12
  "files": [
9
- "dist"
13
+ "dist/index.*"
10
14
  ],
11
15
  "scripts": {
12
16
  "build": "rm -rf ./dist && tsc",
package/dist/bot/Bot.d.ts DELETED
@@ -1,35 +0,0 @@
1
- import { Client, ActivityType } from 'discord.js';
2
- import { BotLog, ConfigLog } from "./BotLog";
3
- import { EmbedColor } from "../manager/messages/EmbedManager";
4
- import { BotMessage } from "./BotMessage";
5
- import { BotInteraction } from "./BotInteraction";
6
- export type BotConfig = {
7
- botIconUrl?: string;
8
- defaultEmbedColor?: number | EmbedColor;
9
- botName?: string;
10
- log?: ConfigLog;
11
- };
12
- export type InternalBotConfig = {
13
- clientId: string;
14
- } & BotConfig;
15
- export type RandomBotActivity = {
16
- type: ActivityType;
17
- message: string;
18
- }[];
19
- export declare class Bot {
20
- static readonly log: typeof BotLog;
21
- static readonly message: typeof BotMessage;
22
- static readonly interaction: typeof BotInteraction;
23
- static _client: Client;
24
- private static criticConfig;
25
- private static _config;
26
- get config(): InternalBotConfig;
27
- get client(): Client;
28
- static get client(): Client;
29
- static get config(): InternalBotConfig;
30
- constructor(client: Client, config: BotConfig);
31
- login(maxTries?: number): Promise<boolean>;
32
- static setActivity(message: string, type: ActivityType): void;
33
- static setRandomActivity(randomActivity: RandomBotActivity, intervalMs?: number | null): void;
34
- }
35
- //# sourceMappingURL=Bot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Bot.d.ts","sourceRoot":"","sources":["../../src/bot/Bot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAC;AAIjE,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAC,UAAU,EAAe,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAExC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAOhD,MAAM,MAAM,SAAS,GAAG;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAA;CACnB,GAAG,SAAS,CAAC;AAEd,MAAM,MAAM,iBAAiB,GAAG;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,EAAE,CAAA;AAEvE,qBAAa,GAAG;IAGZ,gBAAuB,GAAG,gBAAS;IACnC,gBAAuB,OAAO,oBAAa;IAC3C,gBAAuB,WAAW,wBAAiB;IAGnD,OAAc,OAAO,EAAE,MAAM,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAC,YAAY,CAAe;IAC1C,OAAO,CAAC,MAAM,CAAC,OAAO,CAAoB;IAE1C,IAAI,MAAM,IAAI,iBAAiB,CAAwB;IACvD,IAAI,MAAM,IAAI,MAAM,CAAwB;IAE5C,MAAM,KAAK,MAAM,IAAI,MAAM,CAAwB;IACnD,MAAM,KAAK,MAAM,IAAI,iBAAiB,CAAwB;gBAElD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;IAoBhC,KAAK,CAAC,QAAQ,GAAE,MAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAmC1D,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY;IAOtD,MAAM,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,EAAE,UAAU,GAAE,MAAM,GAAG,IAAW;CA0B/F"}
package/dist/bot/Bot.js DELETED
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Bot = void 0;
4
- const discord_js_1 = require("discord.js");
5
- const UnitTime_1 = require("../utils/times/UnitTime");
6
- const Log_1 = require("../utils/Log");
7
- const InternetChecker_1 = require("../utils/network/InternetChecker");
8
- const BotLog_1 = require("./BotLog");
9
- const EmbedManager_1 = require("../manager/messages/EmbedManager");
10
- const BotMessage_1 = require("./BotMessage");
11
- const BotEnv_1 = require("./BotEnv");
12
- const BotInteraction_1 = require("./BotInteraction");
13
- class Bot {
14
- get config() { return Bot._config; }
15
- get client() { return Bot._client; }
16
- static get client() { return Bot._client; }
17
- static get config() { return Bot._config; }
18
- constructor(client, config) {
19
- Log_1.Log.info('----------------------------------------------------');
20
- Log_1.Log.info("Starting Bot");
21
- Bot.criticConfig = { dev: BotEnv_1.BotEnv.dev, token: BotEnv_1.BotEnv.token };
22
- Bot._config = { ...config, clientId: BotEnv_1.BotEnv.clientId };
23
- Bot._client = client;
24
- (async () => {
25
- Log_1.Log.info(`Using discord.js version: ${discord_js_1.version}`);
26
- Log_1.Log.info('Trying to connect to Discord Servers');
27
- await InternetChecker_1.InternetChecker.checkConnection(3);
28
- await this.login();
29
- })();
30
- }
31
- async login(maxTries = 3) {
32
- let success = false;
33
- let tries = 0;
34
- while (!success && tries < maxTries) {
35
- try {
36
- await Bot._client.login(Bot.criticConfig.token);
37
- success = true;
38
- Bot._client.on(discord_js_1.Events.ClientReady, async () => {
39
- if (Bot._client.user) {
40
- await Bot.log.initDiscordLogging();
41
- Log_1.Log.info(`Connected on ${Bot._client.guilds.cache.size} servers as ${Bot._client.user.tag}`);
42
- //Bot._client.guilds.cache.forEach(g => console.log(` - ${g.name}`));
43
- Bot.log.info(EmbedManager_1.EmbedManager.description("Bot Started"));
44
- }
45
- });
46
- }
47
- catch (error) {
48
- Log_1.Log.error(`Connection error : ${error}. Trying again...`);
49
- tries++;
50
- await new Promise(resolve => setTimeout(resolve, UnitTime_1.Time.second.SEC_03.toMilliseconds()));
51
- }
52
- }
53
- if (!success) {
54
- Log_1.Log.error('Impossible to connect the bot after 3 attempts');
55
- return false;
56
- }
57
- return true;
58
- }
59
- static setActivity(message, type) {
60
- if (Bot._client.user) {
61
- Bot._client.user.setActivity({ name: message, type });
62
- Log_1.Log.info(`Activity defined : ${message}`);
63
- }
64
- }
65
- static setRandomActivity(randomActivity, intervalMs = null) {
66
- if (randomActivity.length == 0) {
67
- Log_1.Log.error("Bot.randomActivity = [{}] is empty");
68
- return;
69
- }
70
- const pickRandom = () => {
71
- const random = randomActivity[Math.floor(Math.random() * randomActivity.length)];
72
- Bot.setActivity(random.message, random.type);
73
- return random;
74
- };
75
- if (intervalMs === null) {
76
- pickRandom();
77
- Log_1.Log.info(`Activity set ONCE`);
78
- return;
79
- }
80
- pickRandom();
81
- setInterval(async () => {
82
- pickRandom();
83
- }, intervalMs);
84
- Log_1.Log.info(`Random activity started (every ${Math.round(intervalMs / 60000)}min)`);
85
- return;
86
- }
87
- }
88
- exports.Bot = Bot;
89
- // Static ref
90
- Bot.log = BotLog_1.BotLog;
91
- Bot.message = BotMessage_1.BotMessage;
92
- Bot.interaction = BotInteraction_1.BotInteraction;
@@ -1,6 +0,0 @@
1
- export declare const BotEnv: {
2
- readonly token: string;
3
- readonly dev: boolean;
4
- readonly clientId: string;
5
- };
6
- //# sourceMappingURL=BotEnv.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BotEnv.d.ts","sourceRoot":"","sources":["../../src/bot/BotEnv.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;oBACF,MAAM;kBAKR,OAAO;uBAGF,MAAM;CAUhB,CAAC"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BotEnv = void 0;
4
- const DiscordRegex_1 = require("../utils/DiscordRegex");
5
- exports.BotEnv = {
6
- get token() {
7
- const token = process.env.DISCORD_BOT_TOKEN;
8
- if (!token)
9
- throw new Error('Missing environment variable : DISCORD_BOT_TOKEN');
10
- return token;
11
- },
12
- get dev() {
13
- return process.env.DEV === 'true';
14
- },
15
- get clientId() {
16
- const token = process.env.DISCORD_BOT_CLIENTID;
17
- if (!token)
18
- throw new Error('Missing environment variable : DISCORD_BOT_CLIENTID');
19
- if (!DiscordRegex_1.DiscordRegex.BOT_ID.test(token)) {
20
- throw new Error("Invalid token format");
21
- }
22
- return token;
23
- }
24
- };
@@ -1,21 +0,0 @@
1
- import { BaseInteraction, InteractionResponse, Message } from "discord.js";
2
- import { SendableComponent } from "../manager/builder/SendableComponentBuilder";
3
- export declare class BotInteraction {
4
- /**
5
- * InteractionReplyOptions && InteractionUpdateOptions
6
- * The two have "content", "embeds" & "flags" field, so an internal cast is ok, unless discord/discordjs deprecate it
7
- */
8
- private static buildReplyOptions;
9
- private static buildUpdateOptions;
10
- private static _buildOptions;
11
- static send(interaction: BaseInteraction, content: SendableComponent, ephemeral?: boolean): Promise<InteractionResponse<boolean> | Message<boolean> | boolean>;
12
- static send(interaction: BaseInteraction, content: string, component: SendableComponent, ephemeral?: boolean): Promise<InteractionResponse<boolean> | Message<boolean> | boolean>;
13
- static reply(interaction: BaseInteraction, content: SendableComponent, ephemeral?: boolean): Promise<InteractionResponse<boolean> | Message<boolean> | boolean>;
14
- static reply(interaction: BaseInteraction, content: string, component: SendableComponent, ephemeral?: boolean): Promise<InteractionResponse<boolean> | Message<boolean> | boolean>;
15
- static followUp(interaction: BaseInteraction, content: SendableComponent, ephemeral?: boolean): Promise<InteractionResponse<boolean> | Message<boolean> | boolean>;
16
- static followUp(interaction: BaseInteraction, content: string, component: SendableComponent, ephemeral?: boolean): Promise<InteractionResponse<boolean> | Message<boolean> | boolean>;
17
- static defer(interaction: BaseInteraction): Promise<void>;
18
- static update(interaction: BaseInteraction, content: SendableComponent): Promise<InteractionResponse<boolean> | Message<boolean> | boolean>;
19
- static update(interaction: BaseInteraction, content: string, component: SendableComponent): Promise<InteractionResponse<boolean> | Message<boolean> | boolean>;
20
- }
21
- //# sourceMappingURL=BotInteraction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BotInteraction.d.ts","sourceRoot":"","sources":["../../src/bot/BotInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EAEf,mBAAmB,EAEnB,OAAO,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,iBAAiB,EAA2B,MAAM,6CAA6C,CAAC;AAExG,qBAAa,cAAc;IACvB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAIhC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAIjC,OAAO,CAAC,MAAM,CAAC,aAAa;WAIf,IAAI,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;WACvJ,IAAI,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;WAuB1K,KAAK,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;WACxJ,KAAK,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;WAkB3K,QAAQ,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;WAC3J,QAAQ,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;WAkB9K,KAAK,CAAC,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;WAqBlD,MAAM,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;WACpI,MAAM,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAwBvK"}
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BotInteraction = void 0;
4
- const SendableComponentBuilder_1 = require("../manager/builder/SendableComponentBuilder");
5
- class BotInteraction {
6
- /**
7
- * InteractionReplyOptions && InteractionUpdateOptions
8
- * The two have "content", "embeds" & "flags" field, so an internal cast is ok, unless discord/discordjs deprecate it
9
- */
10
- static buildReplyOptions(content, component, ephemeral) {
11
- return this._buildOptions(content, component, ephemeral);
12
- }
13
- static buildUpdateOptions(content, component) {
14
- return this._buildOptions(content, component, false);
15
- }
16
- static _buildOptions(content, component, ephemeral) {
17
- return SendableComponentBuilder_1.SendableComponentBuilder.buildInteraction(content, component, ephemeral);
18
- }
19
- static async send(interaction, content, component = false, ephemeral = false) {
20
- if (!interaction.isRepliable())
21
- return false;
22
- const options = this.buildReplyOptions(typeof content === 'string' ? content : "", typeof content === 'string' ? component : content, typeof content === 'string' ? ephemeral : component);
23
- if (!interaction.deferred && !interaction.replied) {
24
- return await interaction.reply(options);
25
- }
26
- else {
27
- return await interaction.followUp(options);
28
- }
29
- }
30
- static async reply(interaction, content, component = false, ephemeral = false) {
31
- if (!interaction.isRepliable())
32
- return false;
33
- const options = this.buildReplyOptions(typeof content === 'string' ? content : "", typeof content === 'string' ? component : content, typeof content === 'string' ? ephemeral : component);
34
- return interaction.reply(options);
35
- }
36
- static async followUp(interaction, content, component = false, ephemeral = false) {
37
- if (!interaction.isRepliable())
38
- return false;
39
- const options = this.buildReplyOptions(typeof content === 'string' ? content : "", typeof content === 'string' ? component : content, typeof content === 'string' ? ephemeral : component);
40
- return interaction.followUp(options);
41
- }
42
- static async defer(interaction) {
43
- if (!interaction.isRepliable())
44
- return;
45
- if (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {
46
- if (!interaction.deferred && !interaction.replied) {
47
- await interaction.deferReply();
48
- }
49
- return;
50
- }
51
- if (interaction.isButton() ||
52
- interaction.isAnySelectMenu() ||
53
- interaction.isModalSubmit()) {
54
- if (!interaction.deferred && !interaction.replied) {
55
- await interaction.deferUpdate();
56
- }
57
- }
58
- }
59
- static async update(interaction, content, component) {
60
- if (!interaction.isRepliable())
61
- return false;
62
- const options = this.buildUpdateOptions(typeof content === 'string' ? content : "", typeof content === 'string' ? component : content);
63
- // MessageComponent → update()
64
- if (interaction.isMessageComponent()) {
65
- return await interaction.update(options);
66
- }
67
- // Slash commands → editReply()
68
- if (interaction.deferred || interaction.replied) {
69
- return await interaction.editReply(options);
70
- }
71
- return false;
72
- }
73
- }
74
- exports.BotInteraction = BotInteraction;
@@ -1,52 +0,0 @@
1
- import { EmbedBuilder, Message } from 'discord.js';
2
- export type ConfigLog = {
3
- logChannelId: string;
4
- errorChannelId: string;
5
- info: {
6
- console: boolean;
7
- discord: boolean;
8
- };
9
- error: {
10
- console: boolean;
11
- discord: boolean;
12
- };
13
- warn: {
14
- console: boolean;
15
- discord: boolean;
16
- };
17
- debug: {
18
- console: boolean;
19
- discord: boolean;
20
- };
21
- };
22
- export declare class BotLog {
23
- private static logChannel;
24
- private static errorChannel;
25
- constructor();
26
- static config(): ConfigLog | undefined;
27
- /**
28
- * Initialize Discord logging channels and update Bot.log references
29
- */
30
- static initDiscordLogging(): Promise<void>;
31
- /**
32
- * Send content to specific Discord channel
33
- */
34
- private static _sendToChannel;
35
- /**
36
- * Send INFO log - TEXT or EMBED ! Respecte config.log.info
37
- */
38
- static info(content: string | EmbedBuilder): Promise<Message | void>;
39
- /**
40
- * Send ERROR log - TEXT or EMBED ! Respecte config.log.error
41
- */
42
- static error(content: string | EmbedBuilder): Promise<Message | void>;
43
- /**
44
- * Send WARNING log - TEXT or EMBED ! Respecte config.log.warn
45
- */
46
- static warn(content: string | EmbedBuilder): Promise<Message | void>;
47
- /**
48
- * Send DEBUG log - TEXT or EMBED ! Respecte config.log.debug
49
- */
50
- static debug(content: string | EmbedBuilder): Promise<Message | void>;
51
- }
52
- //# sourceMappingURL=BotLog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BotLog.d.ts","sourceRoot":"","sources":["../../src/bot/BotLog.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,YAAY,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAI9D,MAAM,MAAM,SAAS,GAAG;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAC,CAAA;IAC1C,KAAK,EAAE;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAC,CAAA;IAC3C,IAAI,EAAE;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAC,CAAA;IAC1C,KAAK,EAAE;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAC,CAAA;CAC9C,CAAA;AAED,qBAAa,MAAM;IACf,OAAO,CAAC,MAAM,CAAC,UAAU,CAA4B;IACrD,OAAO,CAAC,MAAM,CAAE,YAAY,CAA4B;;IAIxD,MAAM,CAAC,MAAM,IAAI,SAAS,GAAG,SAAS;IAItC;;OAEG;WACiB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAkCvD;;OAEG;mBACmB,cAAc;IAsBpC;;OAEG;WACU,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAc1E;;OAEG;WACU,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAc3E;;OAEG;WACU,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAY1E;;OAEG;WACU,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;CAY9E"}
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BotLog = void 0;
4
- // src/utils/BotLog.ts
5
- const discord_js_1 = require("discord.js");
6
- const Log_1 = require("../utils/Log");
7
- const Bot_1 = require("./Bot");
8
- class BotLog {
9
- constructor() { }
10
- static config() {
11
- return Bot_1.Bot.config.log;
12
- }
13
- /**
14
- * Initialize Discord logging channels and update Bot.log references
15
- */
16
- static async initDiscordLogging() {
17
- if (!Bot_1.Bot.client.isReady()) {
18
- Log_1.Log.warn('Client not ready for Discord logging init');
19
- return;
20
- }
21
- if (Bot_1.Bot.config.log?.logChannelId) {
22
- try {
23
- const logCh = await Bot_1.Bot.client.channels.fetch(Bot_1.Bot.config.log.logChannelId);
24
- if (logCh?.isTextBased()) {
25
- BotLog.logChannel = logCh;
26
- }
27
- else {
28
- Log_1.Log.warn(`❌ Log channel ${Bot_1.Bot.config.log.logChannelId} invalid`);
29
- }
30
- }
31
- catch (error) {
32
- Log_1.Log.error(`❌ Log channel fetch failed: ${error}`);
33
- }
34
- }
35
- if (Bot_1.Bot.config.log?.errorChannelId) {
36
- try {
37
- const errorCh = await Bot_1.Bot.client.channels.fetch(Bot_1.Bot.config.log.errorChannelId);
38
- if (errorCh?.isTextBased()) {
39
- BotLog.errorChannel = errorCh;
40
- }
41
- else {
42
- Log_1.Log.warn(`❌ Error channel ${Bot_1.Bot.config.log.errorChannelId} invalid`);
43
- }
44
- }
45
- catch (error) {
46
- Log_1.Log.error(`❌ Error channel fetch failed: ${error}`);
47
- }
48
- }
49
- }
50
- /**
51
- * Send content to specific Discord channel
52
- */
53
- static async _sendToChannel(channel, content, prefix = 'info') {
54
- if (!channel)
55
- return;
56
- let msg;
57
- try {
58
- if (content instanceof discord_js_1.EmbedBuilder) {
59
- msg = await channel.send({ embeds: [content] });
60
- }
61
- else {
62
- const timestamp = `\`${new Date().toISOString()}\``;
63
- msg = await channel.send(`${prefix.toUpperCase()} ${timestamp} ${content}`);
64
- }
65
- }
66
- catch (error) {
67
- Log_1.Log.error(`Failed to send to Discord channel: ${error}`);
68
- }
69
- return msg;
70
- }
71
- /**
72
- * Send INFO log - TEXT or EMBED ! Respecte config.log.info
73
- */
74
- static async info(content) {
75
- const logConfig = Bot_1.Bot.config.log;
76
- // 1. CONSOLE selon config (ou défaut ON)
77
- if (!logConfig || logConfig.info.console) {
78
- if (!(content instanceof discord_js_1.EmbedBuilder)) {
79
- Log_1.Log.info(content);
80
- }
81
- }
82
- // 2. Discord seulement si config + channel
83
- if (logConfig?.info.discord && this.logChannel) {
84
- return await this._sendToChannel(this.logChannel, content, 'info');
85
- }
86
- }
87
- /**
88
- * Send ERROR log - TEXT or EMBED ! Respecte config.log.error
89
- */
90
- static async error(content) {
91
- const logConfig = Bot_1.Bot.config.log;
92
- // 1. CONSOLE selon config (ou défaut ON)
93
- if (!logConfig || logConfig.error.console) {
94
- if (!(content instanceof discord_js_1.EmbedBuilder)) {
95
- Log_1.Log.error(content);
96
- }
97
- }
98
- // 2. Discord seulement si config + channel
99
- if (logConfig?.error.discord && this.errorChannel) {
100
- return await this._sendToChannel(this.errorChannel, content, 'error');
101
- }
102
- }
103
- /**
104
- * Send WARNING log - TEXT or EMBED ! Respecte config.log.warn
105
- */
106
- static async warn(content) {
107
- const logConfig = Bot_1.Bot.config.log;
108
- if (!logConfig || logConfig?.warn.console) {
109
- if (!(content instanceof discord_js_1.EmbedBuilder)) {
110
- Log_1.Log.warn(content);
111
- }
112
- }
113
- if (logConfig?.warn.discord && this.logChannel) {
114
- return await this._sendToChannel(this.logChannel, content, 'warn');
115
- }
116
- }
117
- /**
118
- * Send DEBUG log - TEXT or EMBED ! Respecte config.log.debug
119
- */
120
- static async debug(content) {
121
- const logConfig = Bot_1.Bot.config.log;
122
- if (!logConfig || logConfig?.debug.console) {
123
- if (!(content instanceof discord_js_1.EmbedBuilder)) {
124
- Log_1.Log.debug(content);
125
- }
126
- }
127
- if (logConfig?.debug.discord && this.logChannel) {
128
- return await this._sendToChannel(this.logChannel, content, 'debug');
129
- }
130
- }
131
- }
132
- exports.BotLog = BotLog;
133
- BotLog.logChannel = null;
134
- BotLog.errorChannel = null;
@@ -1,20 +0,0 @@
1
- import { TextChannel, DMChannel, ThreadChannel, Message, User, GuildMember, MessageCreateOptions } from 'discord.js';
2
- import { SendableComponent } from "../manager/builder/SendableComponentBuilder";
3
- export declare class BotMessage {
4
- /**
5
- * Send message to any text-based channel
6
- */
7
- static send(channel: TextChannel | DMChannel | ThreadChannel | string, content?: string | null, component?: SendableComponent): Promise<Message | null>;
8
- static send(channel: TextChannel | DMChannel | ThreadChannel | string, content: SendableComponent): Promise<Message | null>;
9
- static send(channel: TextChannel | DMChannel | ThreadChannel | string, content: MessageCreateOptions): Promise<Message | null>;
10
- static sendDM(user: User | GuildMember | string, content?: string, component?: SendableComponent): Promise<Message | null>;
11
- /**
12
- * Quick success message
13
- */
14
- static success(channel: TextChannel | DMChannel | ThreadChannel | User | GuildMember, message: string): Promise<Message | null>;
15
- /**
16
- * Quick error message
17
- */
18
- static error(channel: TextChannel | DMChannel | ThreadChannel | User | GuildMember, message: string): Promise<Message | null>;
19
- }
20
- //# sourceMappingURL=BotMessage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BotMessage.d.ts","sourceRoot":"","sources":["../../src/bot/BotMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,SAAS,EACT,aAAa,EACb,OAAO,EACP,IAAI,EACJ,WAAW,EAAE,oBAAoB,EACpC,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAC,iBAAiB,EAA2B,MAAM,6CAA6C,CAAC;AAGxG,qBAAa,UAAU;IACnB;;OAEG;WACU,IAAI,CAAC,OAAO,EAAC,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;WAC/I,IAAI,CAAC,OAAO,EAAC,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;WACnH,IAAI,CAAC,OAAO,EAAC,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;WAuDtH,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IA4BhI;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,IAAI,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAQ/H;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,IAAI,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;CAOhI"}
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BotMessage = void 0;
4
- const discord_js_1 = require("discord.js");
5
- const Log_1 = require("../utils/Log");
6
- const Bot_1 = require("./Bot");
7
- const EmbedManager_1 = require("../manager/messages/EmbedManager");
8
- const SendableComponentBuilder_1 = require("../manager/builder/SendableComponentBuilder");
9
- class BotMessage {
10
- static async send(channel, content, component) {
11
- try {
12
- if (!channel) {
13
- Log_1.Log.warn('Cannot send message: invalid channel');
14
- return null;
15
- }
16
- if (typeof channel === "string") {
17
- const fetchedChannel = Bot_1.Bot.client.channels.cache.get(channel);
18
- if (!fetchedChannel?.isTextBased()) {
19
- Log_1.Log.warn(`Invalid channel ID: ${channel}`);
20
- return null;
21
- }
22
- channel = fetchedChannel;
23
- }
24
- let messageCreate;
25
- if (typeof content !== "string" && !component) {
26
- if (SendableComponentBuilder_1.SendableComponentBuilder.isSendableComponent(content)) {
27
- messageCreate = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(content);
28
- }
29
- else {
30
- messageCreate = content;
31
- }
32
- }
33
- else {
34
- content = content;
35
- if (content && component) {
36
- messageCreate = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(content, component);
37
- }
38
- else if (content) {
39
- messageCreate = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(content);
40
- }
41
- else if (component) {
42
- messageCreate = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(component);
43
- }
44
- else {
45
- throw new Error("content and component cannot be null at the same time");
46
- }
47
- }
48
- try {
49
- return await channel.send(messageCreate);
50
- }
51
- catch (e) {
52
- throw e;
53
- }
54
- }
55
- catch (e) {
56
- Log_1.Log.error(`Failed to send message : ${e}`);
57
- return null;
58
- }
59
- }
60
- static async sendDM(user, content, component) {
61
- try {
62
- let targetUser;
63
- if (user instanceof discord_js_1.User || user instanceof discord_js_1.GuildMember) {
64
- targetUser = user instanceof discord_js_1.GuildMember ? user.user : user;
65
- }
66
- else {
67
- targetUser = await Bot_1.Bot.client.users.fetch(user);
68
- }
69
- let messageCreate;
70
- if (content && component) {
71
- messageCreate = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(content, component);
72
- }
73
- else if (content) {
74
- messageCreate = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(content);
75
- }
76
- else if (component) {
77
- messageCreate = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(component);
78
- }
79
- else {
80
- throw new Error("content and component cannot be null at the same time");
81
- }
82
- return await targetUser.send(messageCreate);
83
- }
84
- catch (error) {
85
- Log_1.Log.error(`Failed to send message to ${user}: ${error}`);
86
- return null;
87
- }
88
- }
89
- /**
90
- * Quick success message
91
- */
92
- static success(channel, message) {
93
- const embed = EmbedManager_1.EmbedManager.success(message);
94
- if (channel instanceof discord_js_1.User || channel instanceof discord_js_1.GuildMember) {
95
- return this.sendDM(channel, message, embed);
96
- }
97
- return this.send(channel, message, embed);
98
- }
99
- /**
100
- * Quick error message
101
- */
102
- static error(channel, message) {
103
- const embed = EmbedManager_1.EmbedManager.error(message);
104
- if (channel instanceof discord_js_1.User || channel instanceof discord_js_1.GuildMember) {
105
- return this.sendDM(channel, message, embed);
106
- }
107
- return this.send(channel, message, embed);
108
- }
109
- }
110
- exports.BotMessage = BotMessage;