xernerx 3.5.1 → 3.6.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.
Files changed (121) hide show
  1. package/dist/{build → cjs/build}/ContextCommandBuilder.d.ts +31 -28
  2. package/dist/cjs/build/ContextCommandBuilder.js +97 -0
  3. package/dist/cjs/build/EventBuilder.js +44 -0
  4. package/dist/{build → cjs/build}/InhibitorBuilder.d.ts +1 -1
  5. package/dist/cjs/build/InhibitorBuilder.js +37 -0
  6. package/dist/{build → cjs/build}/MessageCommandBuilder.d.ts +23 -17
  7. package/dist/cjs/build/MessageCommandBuilder.js +100 -0
  8. package/dist/{build → cjs/build}/SlashCommandBuilder.d.ts +25 -18
  9. package/dist/cjs/build/SlashCommandBuilder.js +169 -0
  10. package/dist/{client → cjs/client}/XernerxClient.d.ts +1 -0
  11. package/dist/cjs/client/XernerxClient.js +120 -0
  12. package/dist/{handlers → cjs/handlers}/CommandHandler.js +11 -8
  13. package/dist/{handlers → cjs/handlers}/EventHandler.js +6 -3
  14. package/dist/cjs/handlers/Handler.js +308 -0
  15. package/dist/{handlers → cjs/handlers}/InhibitorHandler.js +6 -3
  16. package/dist/cjs/handlers/WebhookHandler.d.ts +7 -0
  17. package/dist/cjs/handlers/WebhookHandler.js +23 -0
  18. package/dist/{main.d.ts → cjs/main.d.ts} +15 -1
  19. package/dist/cjs/main.js +112 -0
  20. package/dist/{models → cjs/models}/CommandArguments.d.ts +1 -1
  21. package/dist/{models → cjs/models}/CommandArguments.js +37 -52
  22. package/dist/cjs/models/Events.js +309 -0
  23. package/dist/cjs/models/Extensions.js +26 -0
  24. package/dist/cjs/models/XernerxUser.d.ts +2 -0
  25. package/dist/cjs/models/XernerxUser.js +12 -0
  26. package/dist/{tools → cjs/tools}/XernerxError.js +4 -1
  27. package/dist/{tools → cjs/tools}/package.d.ts +4 -9
  28. package/dist/{tools → cjs/tools}/package.js +14 -17
  29. package/dist/cjs/types/enums.d.ts +44 -0
  30. package/dist/cjs/types/enums.js +38 -0
  31. package/dist/{types → cjs/types}/interfaces.d.ts +2 -0
  32. package/dist/cjs/types/interfaces.js +2 -0
  33. package/dist/{types → cjs/types}/options.d.ts +13 -0
  34. package/dist/cjs/types/options.js +2 -0
  35. package/dist/{types → cjs/types}/types.d.ts +38 -10
  36. package/dist/cjs/types/types.js +2 -0
  37. package/dist/{utils → cjs/utils}/ClientUtil.d.ts +1 -0
  38. package/dist/{utils → cjs/utils}/ClientUtil.js +73 -84
  39. package/dist/{utils → cjs/utils}/CommandUtil.d.ts +4 -2
  40. package/dist/{utils → cjs/utils}/CommandUtil.js +102 -103
  41. package/dist/{validators → cjs/validators}/CommandValidations.d.ts +6 -1
  42. package/dist/{validators → cjs/validators}/CommandValidations.js +36 -50
  43. package/dist/{validators → cjs/validators}/InhibitorValidations.js +12 -14
  44. package/dist/mjs/build/ContextCommandBuilder.d.ts +63 -0
  45. package/dist/mjs/build/ContextCommandBuilder.js +97 -0
  46. package/dist/mjs/build/EventBuilder.d.ts +21 -0
  47. package/dist/mjs/build/EventBuilder.js +44 -0
  48. package/dist/mjs/build/InhibitorBuilder.d.ts +19 -0
  49. package/dist/mjs/build/InhibitorBuilder.js +37 -0
  50. package/dist/mjs/build/MessageCommandBuilder.d.ts +59 -0
  51. package/dist/mjs/build/MessageCommandBuilder.js +100 -0
  52. package/dist/mjs/build/SlashCommandBuilder.d.ts +65 -0
  53. package/dist/mjs/build/SlashCommandBuilder.js +169 -0
  54. package/dist/mjs/client/XernerxClient.d.ts +29 -0
  55. package/dist/mjs/client/XernerxClient.js +120 -0
  56. package/dist/mjs/handlers/CommandHandler.d.ts +27 -0
  57. package/dist/mjs/handlers/CommandHandler.js +45 -0
  58. package/dist/mjs/handlers/EventHandler.d.ts +13 -0
  59. package/dist/mjs/handlers/EventHandler.js +19 -0
  60. package/dist/mjs/handlers/Handler.d.ts +57 -0
  61. package/dist/mjs/handlers/Handler.js +308 -0
  62. package/dist/mjs/handlers/InhibitorHandler.d.ts +18 -0
  63. package/dist/mjs/handlers/InhibitorHandler.js +24 -0
  64. package/dist/mjs/handlers/WebhookHandler.d.ts +7 -0
  65. package/dist/mjs/handlers/WebhookHandler.js +23 -0
  66. package/dist/{main.js → mjs/main.d.ts} +20 -18
  67. package/dist/mjs/main.js +112 -0
  68. package/dist/mjs/models/CommandArguments.d.ts +17 -0
  69. package/dist/mjs/models/CommandArguments.js +106 -0
  70. package/dist/mjs/models/Events.d.ts +24 -0
  71. package/dist/mjs/models/Events.js +309 -0
  72. package/dist/mjs/models/Extensions.d.ts +7 -0
  73. package/dist/mjs/models/Extensions.js +26 -0
  74. package/dist/mjs/models/XernerxUser.d.ts +2 -0
  75. package/dist/mjs/models/XernerxUser.js +12 -0
  76. package/dist/mjs/tools/XernerxError.d.ts +5 -0
  77. package/dist/mjs/tools/XernerxError.js +11 -0
  78. package/dist/mjs/tools/package.d.ts +44 -0
  79. package/dist/mjs/tools/package.js +45 -0
  80. package/dist/mjs/types/enums.d.ts +44 -0
  81. package/dist/mjs/types/enums.js +38 -0
  82. package/dist/mjs/types/interfaces.d.ts +27 -0
  83. package/dist/mjs/types/interfaces.js +2 -0
  84. package/dist/mjs/types/options.d.ts +254 -0
  85. package/dist/mjs/types/options.js +2 -0
  86. package/dist/mjs/types/types.d.ts +62 -0
  87. package/dist/mjs/types/types.js +2 -0
  88. package/dist/mjs/utils/ClientUtil.d.ts +26 -0
  89. package/dist/mjs/utils/ClientUtil.js +211 -0
  90. package/dist/mjs/utils/CommandUtil.d.ts +58 -0
  91. package/dist/mjs/utils/CommandUtil.js +247 -0
  92. package/dist/mjs/validators/CommandValidations.d.ts +12 -0
  93. package/dist/mjs/validators/CommandValidations.js +169 -0
  94. package/dist/mjs/validators/InhibitorValidations.d.ts +11 -0
  95. package/dist/mjs/validators/InhibitorValidations.js +40 -0
  96. package/package.json +11 -15
  97. package/dist/build/ContextCommandBuilder.js +0 -93
  98. package/dist/build/EventBuilder.js +0 -34
  99. package/dist/build/InhibitorBuilder.js +0 -27
  100. package/dist/build/MessageCommandBuilder.js +0 -90
  101. package/dist/build/SlashCommandBuilder.js +0 -125
  102. package/dist/client/XernerxClient.js +0 -101
  103. package/dist/handlers/Handler.js +0 -250
  104. package/dist/main.cjs +0 -2023
  105. package/dist/models/Events.js +0 -294
  106. package/dist/models/Extensions.js +0 -23
  107. package/dist/types/enums.d.ts +0 -35
  108. package/dist/types/enums.js +0 -35
  109. package/dist/types/interfaces.js +0 -1
  110. package/dist/types/options.js +0 -1
  111. package/dist/types/types.js +0 -1
  112. package/dist/validators/Shapes.js +0 -1
  113. /package/dist/{build → cjs/build}/EventBuilder.d.ts +0 -0
  114. /package/dist/{handlers → cjs/handlers}/CommandHandler.d.ts +0 -0
  115. /package/dist/{handlers → cjs/handlers}/EventHandler.d.ts +0 -0
  116. /package/dist/{handlers → cjs/handlers}/Handler.d.ts +0 -0
  117. /package/dist/{handlers → cjs/handlers}/InhibitorHandler.d.ts +0 -0
  118. /package/dist/{models → cjs/models}/Events.d.ts +0 -0
  119. /package/dist/{models → cjs/models}/Extensions.d.ts +0 -0
  120. /package/dist/{tools → cjs/tools}/XernerxError.d.ts +0 -0
  121. /package/dist/{validators → cjs/validators}/InhibitorValidations.d.ts +0 -0
@@ -0,0 +1,112 @@
1
+ 'use strict';
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k];
13
+ },
14
+ };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }
18
+ : function (o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ });
22
+ var __exportStar =
23
+ (this && this.__exportStar) ||
24
+ function (m, exports) {
25
+ for (var p in m) if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
+ };
27
+ var __importDefault =
28
+ (this && this.__importDefault) ||
29
+ function (mod) {
30
+ return mod && mod.__esModule ? mod : { default: mod };
31
+ };
32
+ Object.defineProperty(exports, '__esModule', { value: true });
33
+ exports.xernerxVersion =
34
+ exports.XernerxError =
35
+ exports.ExtensionBuilder =
36
+ exports.InhibitorBuilder =
37
+ exports.SlashCommandBuilder =
38
+ exports.ContextCommandBuilder =
39
+ exports.MessageCommandBuilder =
40
+ exports.EventBuilder =
41
+ exports.ContextCommandType =
42
+ exports.InhibitorType =
43
+ exports.EventEmitterType =
44
+ exports.CommandType =
45
+ exports.XernerxClient =
46
+ void 0;
47
+ __exportStar(require('discord.js'), exports);
48
+ __exportStar(require('dumfunctions'), exports);
49
+ const xernerx_extension_builder_1 = __importDefault(require('xernerx-extension-builder'));
50
+ exports.ExtensionBuilder = xernerx_extension_builder_1.default;
51
+ const XernerxClient_js_1 = __importDefault(require('./client/XernerxClient.js'));
52
+ exports.XernerxClient = XernerxClient_js_1.default;
53
+ const EventBuilder_js_1 = __importDefault(require('./build/EventBuilder.js'));
54
+ exports.EventBuilder = EventBuilder_js_1.default;
55
+ const InhibitorBuilder_js_1 = __importDefault(require('./build/InhibitorBuilder.js'));
56
+ exports.InhibitorBuilder = InhibitorBuilder_js_1.default;
57
+ const MessageCommandBuilder_js_1 = __importDefault(require('./build/MessageCommandBuilder.js'));
58
+ exports.MessageCommandBuilder = MessageCommandBuilder_js_1.default;
59
+ const ContextCommandBuilder_js_1 = __importDefault(require('./build/ContextCommandBuilder.js'));
60
+ exports.ContextCommandBuilder = ContextCommandBuilder_js_1.default;
61
+ const SlashCommandBuilder_js_1 = __importDefault(require('./build/SlashCommandBuilder.js'));
62
+ exports.SlashCommandBuilder = SlashCommandBuilder_js_1.default;
63
+ const enums_js_1 = require('./types/enums.js');
64
+ Object.defineProperty(exports, 'CommandType', {
65
+ enumerable: true,
66
+ get: function () {
67
+ return enums_js_1.CommandType;
68
+ },
69
+ });
70
+ Object.defineProperty(exports, 'EventEmitterType', {
71
+ enumerable: true,
72
+ get: function () {
73
+ return enums_js_1.EventEmitterType;
74
+ },
75
+ });
76
+ Object.defineProperty(exports, 'ContextCommandType', {
77
+ enumerable: true,
78
+ get: function () {
79
+ return enums_js_1.ContextCommandType;
80
+ },
81
+ });
82
+ Object.defineProperty(exports, 'InhibitorType', {
83
+ enumerable: true,
84
+ get: function () {
85
+ return enums_js_1.InhibitorType;
86
+ },
87
+ });
88
+ const XernerxError_js_1 = __importDefault(require('./tools/XernerxError.js'));
89
+ exports.XernerxError = XernerxError_js_1.default;
90
+ const package_js_1 = __importDefault(require('./tools/package.js'));
91
+ const xernerxVersion = package_js_1.default.version;
92
+ exports.xernerxVersion = xernerxVersion;
93
+ exports.default = {
94
+ // Client
95
+ Client: XernerxClient_js_1.default,
96
+ XernerxClient: XernerxClient_js_1.default,
97
+ // Enums
98
+ CommandType: enums_js_1.CommandType,
99
+ EventEmitterType: enums_js_1.EventEmitterType,
100
+ InhibitorType: enums_js_1.InhibitorType,
101
+ ContextCommandType: enums_js_1.ContextCommandType,
102
+ // Builds
103
+ EventBuilder: EventBuilder_js_1.default,
104
+ MessageCommandBuilder: MessageCommandBuilder_js_1.default,
105
+ ContextCommandBuilder: ContextCommandBuilder_js_1.default,
106
+ SlashCommandBuilder: SlashCommandBuilder_js_1.default,
107
+ InhibitorBuilder: InhibitorBuilder_js_1.default,
108
+ ExtensionBuilder: xernerx_extension_builder_1.default,
109
+ XernerxError: XernerxError_js_1.default,
110
+ // Constants
111
+ version: xernerxVersion,
112
+ };
@@ -13,5 +13,5 @@ interface Flag {
13
13
  interface Argument {
14
14
  [index: string]: string | number | null;
15
15
  }
16
- export declare function messageArguments(message: XernerxMessage, command: MessageCommandBuilder): Promise<import("discord.js").Message<boolean> | Flag | Argument | undefined>;
16
+ export declare function messageArguments(message: XernerxMessage, command: MessageCommandBuilder): Promise<import('discord.js').Message<boolean> | Flag | Argument | undefined>;
17
17
  export {};
@@ -1,4 +1,7 @@
1
- export class InteractionArguments {
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.messageArguments = exports.InteractionArguments = void 0;
4
+ class InteractionArguments {
2
5
  interaction;
3
6
  constructor(interaction) {
4
7
  this.interaction = interaction;
@@ -19,23 +22,24 @@ export class InteractionArguments {
19
22
  return options;
20
23
  }
21
24
  }
22
- export async function messageArguments(message, command) {
23
- let args = { flags: {} }, separator = command.separator || ' ', i = 0;
24
- if (!command.args)
25
- return;
25
+ exports.InteractionArguments = InteractionArguments;
26
+ async function messageArguments(message, command) {
27
+ let args = { flags: {} },
28
+ separator = command.separator || ' ',
29
+ i = 0;
30
+ if (!command.args) return;
26
31
  command.args
27
32
  .filter((c) => c.type == 'flag')
28
33
  .map((flag) => {
29
- args = args;
30
- for (const flg of message.content.matchAll(flag.match)) {
31
- if (flag.match == flg) {
32
- message.content = message.content.replace(flag.match, '');
33
- args.flags[flag.name] = true;
34
+ args = args;
35
+ for (const flg of message.content.matchAll(flag.match)) {
36
+ if (flag.match == flg) {
37
+ message.content = message.content.replace(flag.match, '');
38
+ args.flags[flag.name] = true;
39
+ }
34
40
  }
35
- }
36
- if (!args.flags[flag.name])
37
- args.flags[flag.name] = false;
38
- });
41
+ if (!args.flags[flag.name]) args.flags[flag.name] = false;
42
+ });
39
43
  for (const argument of command.args) {
40
44
  args = args;
41
45
  let content = message.content
@@ -48,74 +52,55 @@ export async function messageArguments(message, command) {
48
52
  if (content.join(separator) != '' && argument.type !== 'flag') {
49
53
  if (argument?.content?.includes(content[0])) {
50
54
  args[argument.name] = content[0];
51
- }
52
- else if (argument.type == 'string') {
55
+ } else if (argument.type == 'string') {
53
56
  args[argument.name] = content[0];
54
- }
55
- else if (argument.type == 'number') {
57
+ } else if (argument.type == 'number') {
56
58
  args[argument.name] = parseInt(content[0]);
57
- }
58
- else if (argument.type == 'boolean') {
59
- if (content[0]?.toLowerCase() != 'true' && content[0]?.toLowerCase() != 'false')
60
- content[0] = null;
59
+ } else if (argument.type == 'boolean') {
60
+ if (content[0]?.toLowerCase() != 'true' && content[0]?.toLowerCase() != 'false') content[0] = null;
61
61
  args[argument.name] = content[0];
62
- }
63
- else if (argument.type == 'user') {
62
+ } else if (argument.type == 'user') {
64
63
  let user = message.client.users.cache.find((u) => u?.username?.toLowerCase()?.includes(content[0])) || null;
65
64
  try {
66
65
  user = (await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g, ''))) || null;
67
- }
68
- catch (e) {
66
+ } catch (e) {
69
67
  user = null;
70
68
  }
71
69
  args[argument.name] = user;
72
- }
73
- else if (argument.type == 'role') {
70
+ } else if (argument.type == 'role') {
74
71
  let role = message.guild?.roles.cache.find((r) => r?.name?.toLowerCase()?.includes(content[0])) || null;
75
72
  try {
76
73
  role = (await message.guild?.roles.fetch(role?.id || content[0].replace(/<@&?|>/g, ''))) || null;
77
- }
78
- catch (e) {
74
+ } catch (e) {
79
75
  role = null;
80
76
  }
81
77
  args[argument.name] = role;
82
- }
83
- else if (argument.type == 'member') {
78
+ } else if (argument.type == 'member') {
84
79
  let member = message.guild?.members.cache.find((m) => m?.nickname?.toLowerCase()?.includes(content[0]) || m?.user?.username?.toLowerCase()?.includes(content[0])) || null;
85
80
  try {
86
81
  member = (await message.guild?.members.fetch(member?.id || content[0].replace(/<@!?|>/g, ''))) || null;
87
- }
88
- catch (e) {
82
+ } catch (e) {
89
83
  member = null;
90
84
  }
91
85
  args[argument.name] = member;
92
- }
93
- else if (argument.type == 'channel') {
86
+ } else if (argument.type == 'channel') {
94
87
  let channel = message.guild?.channels.cache.find((c) => c?.name?.toLowerCase()?.includes(content[0]));
95
88
  try {
96
89
  channel = await message.client.channels.fetch(channel?.id || content[0].replace(/<#|>/g, ''));
97
- }
98
- catch (e) {
90
+ } catch (e) {
99
91
  channel = null;
100
92
  }
101
93
  args[argument.name] = channel;
102
- }
103
- else if (argument.type == 'rest') {
94
+ } else if (argument.type == 'rest') {
104
95
  args[argument.name] = content.join(separator);
105
96
  break;
106
- }
107
- else if (argument.prompt) {
108
- if (argument.prompt.reply)
109
- return message.util?.reply(argument.prompt.reply);
110
- else if (argument.prompt.send)
111
- return message.channel.send(argument.prompt.send);
112
- }
113
- else
114
- args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
97
+ } else if (argument.prompt) {
98
+ if (argument.prompt.reply) return message.util?.reply(argument.prompt.reply);
99
+ else if (argument.prompt.send) return message.channel.send(argument.prompt.send);
100
+ } else args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
115
101
  i++;
116
- }
117
- else
118
- args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
102
+ } else args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
119
103
  }
120
104
  return args;
121
105
  }
106
+ exports.messageArguments = messageArguments;
@@ -0,0 +1,309 @@
1
+ 'use strict';
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod };
6
+ };
7
+ Object.defineProperty(exports, '__esModule', { value: true });
8
+ exports.CommandsDeploy = exports.ContextCommandEvents = exports.SlashCommandEvents = exports.MessageCommandEvents = void 0;
9
+ const discord_js_1 = require('discord.js');
10
+ const CommandUtil_js_1 = require('../utils/CommandUtil.js');
11
+ const CommandArguments_js_1 = require('./CommandArguments.js');
12
+ const CommandValidations_js_1 = __importDefault(require('../validators/CommandValidations.js'));
13
+ const dumfunctions_1 = require('dumfunctions');
14
+ const InhibitorValidations_js_1 = require('../validators/InhibitorValidations.js');
15
+ const XernerxUser_js_1 = __importDefault(require('./XernerxUser.js'));
16
+ class MessageCommandEvents {
17
+ client;
18
+ constructor(client) {
19
+ this.client = client;
20
+ }
21
+ messageCreate() {
22
+ this.client.on('messageCreate', async (message) => {
23
+ if (!message.author.bot) {
24
+ let command = undefined,
25
+ px = undefined;
26
+ message.author = await (0, XernerxUser_js_1.default)(message);
27
+ message.util = new CommandUtil_js_1.MessageCommandUtil(this.client, message);
28
+ const commands = this.client.commands.message;
29
+ commands
30
+ .filter((c) => !c.regex)
31
+ .map(async (cmd) => {
32
+ if (cmd.prefix) {
33
+ cmd.prefix.map((prefix) => {
34
+ if (message.content.startsWith(prefix)) {
35
+ command = message.content.replace(prefix, '').split(/ +/).shift();
36
+ px = prefix;
37
+ }
38
+ });
39
+ }
40
+ if (this.client.handlerOptions.message?.prefix) {
41
+ const prefix = Array.isArray(this.client.handlerOptions.message.prefix) ? this.client.handlerOptions.message.prefix : [this.client.handlerOptions.message.prefix];
42
+ prefix.map((prefix) => {
43
+ if (message.content.startsWith(prefix)) {
44
+ command = message.content.replace(prefix, '').split(/ +/).shift();
45
+ px = prefix;
46
+ }
47
+ });
48
+ }
49
+ if (this.client.handlerOptions.message?.allowMention) {
50
+ if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
51
+ command = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
52
+ px = 'MentionPrefix';
53
+ }
54
+ }
55
+ const prefix = Array.isArray(this.client.handlerOptions.message?.prefix) ? this.client.handlerOptions.message?.prefix : [this.client.handlerOptions.message?.prefix];
56
+ if (
57
+ (cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
58
+ (cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')
59
+ ) {
60
+ try {
61
+ if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
62
+ const inhibitor = new InhibitorValidations_js_1.InhibitorValidation(this.client, message, command);
63
+ if ((0, CommandValidations_js_1.default)(message, cmd, this.client)) return;
64
+ if (await inhibitor.inhibit()) return;
65
+ if (cmd.conditions && (await cmd.conditions(message, await (0, CommandArguments_js_1.messageArguments)(message, cmd)))) return;
66
+ await cmd.exec(message, await (0, CommandArguments_js_1.messageArguments)(message, cmd));
67
+ this.client.emit('commandRun', message, cmd);
68
+ } catch (error) {
69
+ return this.client.emit('commandError', message, error, cmd);
70
+ }
71
+ }
72
+ });
73
+ }
74
+ });
75
+ }
76
+ messageUpdate() {
77
+ this.client.on('messageUpdate', async (old, message) => {
78
+ message = message;
79
+ if (!message.author?.bot) {
80
+ let command = undefined,
81
+ px = undefined;
82
+ message.author = await (0, XernerxUser_js_1.default)(message);
83
+ message.util = new CommandUtil_js_1.MessageCommandUtil(this.client, message);
84
+ const commands = this.client.commands.message;
85
+ commands
86
+ .filter((c) => !c.regex)
87
+ .map(async (cmd) => {
88
+ if (cmd.prefix) {
89
+ cmd.prefix.map((prefix) => {
90
+ if (message?.content?.startsWith(prefix)) {
91
+ command = message.content.replace(prefix, '').split(/ +/).shift();
92
+ px = prefix;
93
+ }
94
+ });
95
+ }
96
+ if (this.client.handlerOptions.message?.prefix) {
97
+ const prefix = Array.isArray(this.client.handlerOptions.message.prefix) ? this.client.handlerOptions.message.prefix : [this.client.handlerOptions.message.prefix];
98
+ prefix.map((prefix) => {
99
+ if (message?.content?.startsWith(prefix)) {
100
+ command = message.content.replace(prefix, '').split(/ +/).shift();
101
+ px = prefix;
102
+ }
103
+ });
104
+ }
105
+ if (this.client.handlerOptions.message?.allowMention) {
106
+ if (message.mentions.users.has(this.client.user?.id || '') || message.mentions.repliedUser?.id === this.client.user?.id) {
107
+ command = message?.content?.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
108
+ px = 'MentionPrefix';
109
+ }
110
+ }
111
+ const prefix = Array.isArray(this.client.handlerOptions.message?.prefix) ? this.client.handlerOptions.message?.prefix : [this.client.handlerOptions.message?.prefix];
112
+ if (
113
+ (cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
114
+ (cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')
115
+ ) {
116
+ try {
117
+ if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
118
+ message = message;
119
+ const inhibitor = new InhibitorValidations_js_1.InhibitorValidation(this.client, message, command);
120
+ if ((0, CommandValidations_js_1.default)(message, cmd, this.client)) return;
121
+ if (await inhibitor.inhibit()) return;
122
+ if (cmd.conditions && (await cmd.conditions(message, await (0, CommandArguments_js_1.messageArguments)(message, cmd)))) return;
123
+ await cmd.exec(message, await (0, CommandArguments_js_1.messageArguments)(message, cmd));
124
+ this.client.emit('commandRun', message, cmd);
125
+ } catch (error) {
126
+ return this.client.emit('commandError', message, error, cmd);
127
+ }
128
+ }
129
+ });
130
+ }
131
+ });
132
+ }
133
+ messageDelete() {
134
+ this.client.on('messageDelete', async (message) => {
135
+ if (this.client.cache.messages.has(message.id) && this.client.handlerOptions.message?.handleDeletes) {
136
+ try {
137
+ if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
138
+ message.author = await (0, XernerxUser_js_1.default)(message);
139
+ const msg = this.client.cache.messages.get(message.id);
140
+ const response = await message.channel.messages.fetch(msg?.response);
141
+ await response.delete();
142
+ } catch (error) {
143
+ this.client.emit('commandError', message, error, null);
144
+ }
145
+ }
146
+ });
147
+ }
148
+ }
149
+ exports.MessageCommandEvents = MessageCommandEvents;
150
+ class SlashCommandEvents {
151
+ client;
152
+ constructor(client) {
153
+ this.client = client;
154
+ }
155
+ slashCreate() {
156
+ this.client.on('interactionCreate', async (interaction) => {
157
+ interaction.util = new CommandUtil_js_1.InteractionCommandUtil(this.client, interaction);
158
+ interaction.author = await (0, XernerxUser_js_1.default)(interaction);
159
+ if (interaction.type === discord_js_1.InteractionType.ApplicationCommand) {
160
+ if (this.client.commands.slash.has(interaction.commandName)) {
161
+ let command = this.client.commands.slash.get(interaction.commandName);
162
+ const argumentsInfo = new CommandArguments_js_1.InteractionArguments(interaction);
163
+ try {
164
+ const inhibitor = new InhibitorValidations_js_1.InhibitorValidation(this.client, interaction, command);
165
+ if (await inhibitor.inhibit()) return;
166
+ if ((0, CommandValidations_js_1.default)(interaction, command, this.client)) return;
167
+ if (command.defer?.reply !== false && this.client.handlerOptions.slash?.defer?.reply)
168
+ await interaction.deferReply({
169
+ ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral,
170
+ fetchReply: this.client.handlerOptions.slash?.defer?.fetchReply,
171
+ });
172
+ if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
173
+ await interaction.deferReply({
174
+ ephemeral: command.defer?.ephemeral,
175
+ fetchReply: command.defer?.fetchReply,
176
+ });
177
+ if (
178
+ command.conditions &&
179
+ (await command.conditions(interaction, {
180
+ group: argumentsInfo.group(),
181
+ subcommand: argumentsInfo.subcommand(),
182
+ args: await argumentsInfo.arguments(),
183
+ }))
184
+ )
185
+ return;
186
+ await command.exec(interaction, {
187
+ group: argumentsInfo.group(),
188
+ subcommand: argumentsInfo.subcommand(),
189
+ args: await argumentsInfo.arguments(),
190
+ });
191
+ this.client.emit('commandRun', interaction, command);
192
+ } catch (error) {
193
+ this.client.emit('commandError', interaction, error, command);
194
+ }
195
+ }
196
+ }
197
+ });
198
+ }
199
+ }
200
+ exports.SlashCommandEvents = SlashCommandEvents;
201
+ class ContextCommandEvents {
202
+ client;
203
+ constructor(client) {
204
+ this.client = client;
205
+ }
206
+ contextCreate() {
207
+ this.client.on('interactionCreate', async (interaction) => {
208
+ interaction.util = new CommandUtil_js_1.InteractionCommandUtil(this.client, interaction);
209
+ interaction.author = await (0, XernerxUser_js_1.default)(interaction);
210
+ if (interaction.type === discord_js_1.InteractionType.ApplicationCommand) {
211
+ if (this.client.commands.context.has(interaction.commandName)) {
212
+ let command = this.client.commands.context.get(interaction.commandName);
213
+ try {
214
+ const inhibitor = new InhibitorValidations_js_1.InhibitorValidation(this.client, interaction, command);
215
+ if ((0, CommandValidations_js_1.default)(interaction, command, this.client)) return;
216
+ if (await inhibitor.inhibit()) return;
217
+ if (command.conditions && (await command.conditions(interaction))) return;
218
+ if (command.defer?.reply !== false && this.client.handlerOptions.context?.defer?.reply)
219
+ await interaction.deferReply({
220
+ ephemeral: this.client.handlerOptions.context?.defer?.ephemeral,
221
+ fetchReply: this.client.handlerOptions.context?.defer?.fetchReply,
222
+ });
223
+ if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
224
+ await interaction.deferReply({
225
+ ephemeral: command.defer?.ephemeral,
226
+ fetchReply: command.defer?.fetchReply,
227
+ });
228
+ let args = {};
229
+ if (command.type === 3) args = await interaction.channel.messages.fetch(interaction.targetId);
230
+ if (command.type === 2) args = await this.client.users.fetch(interaction.targetId);
231
+ await command.exec(interaction, args);
232
+ this.client.emit('commandRun', interaction, command);
233
+ } catch (error) {
234
+ this.client.emit('commandError', interaction, error, command);
235
+ }
236
+ }
237
+ }
238
+ });
239
+ }
240
+ }
241
+ exports.ContextCommandEvents = ContextCommandEvents;
242
+ class CommandsDeploy {
243
+ client;
244
+ constructor(client) {
245
+ this.client = client;
246
+ }
247
+ deploy() {
248
+ this.client.once('ready', async (client) => {
249
+ const slashCommands = [],
250
+ contextCommands = [];
251
+ this.client.commands.context.map((command) => (command.data ? contextCommands.push(command.data.toJSON()) : null));
252
+ this.client.commands.slash.map((command) => (command.data ? slashCommands.push(command.data.toJSON()) : null));
253
+ try {
254
+ const global = {
255
+ slash: this.client.handlerOptions.slash?.global,
256
+ context: this.client.handlerOptions.context?.global,
257
+ };
258
+ const guild = {
259
+ slash: this.client.handlerOptions.slash?.guildId,
260
+ context: this.client.handlerOptions.context?.guildId,
261
+ };
262
+ if (!guild.slash && !guild.context) return;
263
+ if (global.slash && global.context) {
264
+ if (guild.slash !== guild.context)
265
+ console.info(
266
+ dumfunctions_1.Style.log(
267
+ `Xernerx | Warning: slash and context commands are both set to global, but don't have a matching guildId, using ${
268
+ (await this.client.guilds.fetch(this.client.handlerOptions.slash?.guildId)).name
269
+ }!`,
270
+ { color: dumfunctions_1.Style.TextColor.Red }
271
+ )
272
+ );
273
+ this.put('global', guild.slash, [...contextCommands, ...slashCommands]);
274
+ this.put('guild', guild.slash, []);
275
+ }
276
+ if (global.slash && global.context === false) {
277
+ this.put('global', guild.slash, slashCommands);
278
+ }
279
+ if (global.slash === false && global.context) {
280
+ this.put('global', guild.context, contextCommands);
281
+ }
282
+ if (global.slash === false && global.context === false) {
283
+ this.put('guild', guild.slash, [...contextCommands, ...slashCommands]);
284
+ }
285
+ if (this.client.handlerOptions.context?.logging || this.client.handlerOptions.slash?.logging)
286
+ console.info(
287
+ dumfunctions_1.Style.log(
288
+ `Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? 'globally' : 'locally'} and ${contextCommands.length} context commands ${
289
+ global.context ? 'globally' : 'locally'
290
+ }.`,
291
+ { color: dumfunctions_1.Style.TextColor.Purple }
292
+ )
293
+ );
294
+ } catch (error) {
295
+ console.error(
296
+ dumfunctions_1.Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
297
+ color: dumfunctions_1.Style.BackgroundColor.Red,
298
+ })
299
+ );
300
+ }
301
+ });
302
+ }
303
+ put(type, guild, body) {
304
+ const rest = new discord_js_1.REST({ version: discord_js_1.GatewayVersion }).setToken(this.client.token);
305
+ if (type === 'guild') rest.put(discord_js_1.Routes.applicationGuildCommands(this.client.user?.id, guild), { body });
306
+ else rest.put(discord_js_1.Routes.applicationCommands(this.client.user?.id), { body });
307
+ }
308
+ }
309
+ exports.CommandsDeploy = CommandsDeploy;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ const dumfunctions_1 = require('dumfunctions');
4
+ class Extensions {
5
+ client;
6
+ constructor(client) {
7
+ this.client = client;
8
+ }
9
+ async load(extensions, logging = false) {
10
+ const exts = [];
11
+ extensions.map((extension) => {
12
+ try {
13
+ this.client.extensions[extension.name] = extension;
14
+ exts.push(extension.name);
15
+ } catch (error) {
16
+ console.error(
17
+ dumfunctions_1.Style.log(`Xernerx | An error occurred trying to load ${extension.name}, error: <${error}>`, {
18
+ color: dumfunctions_1.Style.BackgroundColor.Red,
19
+ })
20
+ );
21
+ }
22
+ });
23
+ if (logging) console.info(dumfunctions_1.Style.log(`Xernerx | Loaded ${exts.length} extensions: ${exts.join(', ')}`, { color: dumfunctions_1.Style.TextColor.Cyan }));
24
+ }
25
+ }
26
+ exports.default = Extensions;
@@ -0,0 +1,2 @@
1
+ import { XernerxUser } from '../types/types.js';
2
+ export default function XernerxUser(interaction: any): Promise<XernerxUser>;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ const dbl_sdk_1 = require('dbl-sdk');
4
+ async function XernerxUser(interaction) {
5
+ const user = interaction.user || interaction.author;
6
+ user.owner = interaction.client.util.isOwner(user.id);
7
+ user.voter = interaction.client.handlerOptions?.webhook?.topgg?.token
8
+ ? await (0, dbl_sdk_1.hasVoted)(user.id, interaction.client.user.id, interaction.client.handlerOptions.webhook.topgg.token, 'top.gg')
9
+ : false;
10
+ return user;
11
+ }
12
+ exports.default = XernerxUser;
@@ -1,4 +1,6 @@
1
- export default class XernerxError {
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ class XernerxError {
2
4
  name;
3
5
  message;
4
6
  constructor(message) {
@@ -6,3 +8,4 @@ export default class XernerxError {
6
8
  this.message = message || '';
7
9
  }
8
10
  }
11
+ exports.default = XernerxError;
@@ -1,21 +1,14 @@
1
1
  declare const _default: {
2
2
  name: string;
3
3
  version: string;
4
- type: string;
5
4
  description: string;
6
5
  main: string;
6
+ module: string;
7
7
  keywords: string[];
8
8
  author: string;
9
9
  license: string;
10
10
  homepage: string;
11
11
  packageManager: string;
12
- exports: {
13
- import: string;
14
- require: string;
15
- types: string;
16
- node: null;
17
- default: null;
18
- };
19
12
  scripts: {
20
13
  start: string;
21
14
  patch: string;
@@ -24,7 +17,10 @@ declare const _default: {
24
17
  site: string;
25
18
  commit: string;
26
19
  write: string;
20
+ format: string;
27
21
  build: string;
22
+ 'build:esm': string;
23
+ 'build:cjs': string;
28
24
  };
29
25
  repository: {
30
26
  type: string;
@@ -42,7 +38,6 @@ declare const _default: {
42
38
  };
43
39
  devDependencies: {
44
40
  prettier: string;
45
- tsup: string;
46
41
  typescript: string;
47
42
  };
48
43
  };