xernerx 3.5.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/build/ContextCommandBuilder.d.ts +47 -0
  2. package/dist/build/ContextCommandBuilder.js +78 -0
  3. package/dist/{cjs/build → build}/EventBuilder.d.ts +7 -6
  4. package/dist/build/EventBuilder.js +35 -0
  5. package/dist/build/InhibitorBuilder.d.ts +17 -0
  6. package/dist/build/InhibitorBuilder.js +26 -0
  7. package/dist/build/MessageCommandBuilder.d.ts +43 -0
  8. package/dist/build/MessageCommandBuilder.js +71 -0
  9. package/dist/{cjs/build → build}/SlashCommandBuilder.d.ts +16 -31
  10. package/dist/build/SlashCommandBuilder.js +122 -0
  11. package/dist/build copy/ContextCommandBuilder.d.ts +37 -0
  12. package/dist/build copy/ContextCommandBuilder.js +88 -0
  13. package/dist/{mjs/build/EventBuilder.d.ts → build copy/EventBuilder.d.ts } +4 -4
  14. package/dist/build copy/EventBuilder.js +34 -0
  15. package/dist/{cjs/build/InhibitorBuilder.d.ts → build copy/InhibitorBuilder.d.ts } +2 -2
  16. package/dist/build copy/InhibitorBuilder.js +27 -0
  17. package/dist/{cjs/build/MessageCommandBuilder.d.ts → build copy/MessageCommandBuilder.d.ts } +14 -34
  18. package/dist/build copy/MessageCommandBuilder.js +90 -0
  19. package/dist/build copy/SlashCommandBuilder.d.ts +41 -0
  20. package/dist/build copy/SlashCommandBuilder.js +122 -0
  21. package/dist/client/DBLClient.d.ts +8 -0
  22. package/dist/client/DBLClient.js +15 -0
  23. package/dist/client/Top.ggClient.d.ts +1 -0
  24. package/dist/client/Top.ggClient.js +1 -0
  25. package/dist/client/XernerxClient.d.ts +54 -0
  26. package/dist/client/XernerxClient.js +90 -0
  27. package/dist/events/messageCreate.d.ts +1 -0
  28. package/dist/events/messageCreate.js +1 -0
  29. package/dist/functions/AsyncFunctions.d.ts +1 -0
  30. package/dist/functions/AsyncFunctions.js +1 -0
  31. package/dist/functions/delay.d.ts +1 -0
  32. package/dist/functions/delay.js +3 -0
  33. package/dist/functions/deploy.d.ts +2 -0
  34. package/dist/functions/deploy.js +29 -0
  35. package/dist/functions/getPermissionBitField.d.ts +2 -0
  36. package/dist/functions/getPermissionBitField.js +17 -0
  37. package/dist/functions/hasVoted.d.ts +1 -0
  38. package/dist/functions/hasVoted.js +1 -0
  39. package/dist/functions/isOwner.d.ts +3 -0
  40. package/dist/functions/isOwner.js +3 -0
  41. package/dist/functions/isVoter.d.ts +3 -0
  42. package/dist/functions/isVoter.js +5 -0
  43. package/dist/functions/load.d.ts +3 -0
  44. package/dist/functions/load.js +32 -0
  45. package/dist/functions/reload.d.ts +2 -0
  46. package/dist/functions/reload.js +39 -0
  47. package/dist/functions/sendWebhook.d.ts +2 -0
  48. package/dist/functions/sendWebhook.js +12 -0
  49. package/dist/functions/voted.d.ts +1 -0
  50. package/dist/functions/voted.js +1 -0
  51. package/dist/functions/xernerxUser.d.ts +3 -0
  52. package/dist/functions/xernerxUser.js +8 -0
  53. package/dist/handlers/CommandHandler.d.ts +13 -0
  54. package/dist/handlers/CommandHandler.js +220 -0
  55. package/dist/handlers/EventHandler.d.ts +7 -0
  56. package/dist/handlers/EventHandler.js +24 -0
  57. package/dist/handlers/ExtensionHandler.d.ts +7 -0
  58. package/dist/handlers/ExtensionHandler.js +19 -0
  59. package/dist/handlers/Handler.d.ts +14 -0
  60. package/dist/handlers/Handler.js +36 -0
  61. package/dist/handlers/InhibitorHandler.d.ts +7 -0
  62. package/dist/handlers/InhibitorHandler.js +24 -0
  63. package/dist/handlers/WebhookHandler.d.ts +7 -0
  64. package/dist/handlers/WebhookHandler.js +50 -0
  65. package/dist/main.d.ts +11 -0
  66. package/dist/main.js +11 -0
  67. package/dist/models/Arguments.d.ts +15 -0
  68. package/dist/models/Arguments.js +129 -0
  69. package/dist/{mjs/models → models}/CommandArguments.js +2 -7
  70. package/dist/{mjs/models → models}/Events.js +44 -54
  71. package/dist/models/Extensions.js +23 -0
  72. package/dist/models/XernerxUser.d.ts +2 -0
  73. package/dist/models/XernerxUser.js +9 -0
  74. package/dist/tools/XernerxError.d.ts +6 -0
  75. package/dist/tools/XernerxError.js +10 -0
  76. package/dist/tools/XernerxLog.d.ts +13 -0
  77. package/dist/tools/XernerxLog.js +30 -0
  78. package/dist/tools/classes.d.ts +6 -0
  79. package/dist/tools/classes.js +10 -0
  80. package/dist/tools/loggers.d.ts +4 -0
  81. package/dist/tools/loggers.js +4 -0
  82. package/dist/{cjs/tools → tools}/package.d.ts +5 -9
  83. package/dist/{cjs/tools → tools}/package.js +12 -18
  84. package/dist/{cjs/types → types}/enums.js +8 -11
  85. package/dist/types/extenders.d.ts +23 -0
  86. package/dist/types/extenders.js +1 -0
  87. package/dist/types/interfaces.d.ts +224 -0
  88. package/dist/types/interfaces.js +1 -0
  89. package/dist/{cjs/types → types}/options.d.ts +13 -0
  90. package/dist/types/options.js +1 -0
  91. package/dist/types/types.d.ts +181 -0
  92. package/dist/types/types.js +1 -0
  93. package/dist/utils/ClientUtil.d.ts +6 -0
  94. package/dist/utils/ClientUtil.js +7 -0
  95. package/dist/{cjs/utils → utils}/CommandUtil.js +14 -29
  96. package/dist/utils/InteractionArguments.d.ts +1 -0
  97. package/dist/utils/InteractionArguments.js +1 -0
  98. package/dist/utils/InteractionUtil.d.ts +10 -0
  99. package/dist/utils/InteractionUtil.js +15 -0
  100. package/dist/utils/MessageUtil.d.ts +11 -0
  101. package/dist/utils/MessageUtil.js +42 -0
  102. package/dist/utils/Util.d.ts +5 -0
  103. package/dist/utils/Util.js +6 -0
  104. package/dist/{mjs/validators → validators}/CommandValidations.js +11 -14
  105. package/dist/validators/InhibitorValidations.d.ts +18 -0
  106. package/dist/validators/InhibitorValidations.js +34 -0
  107. package/dist/validators/commandValidation.d.ts +6 -0
  108. package/dist/validators/commandValidation.js +48 -0
  109. package/dist/validators/commands.d.ts +4 -0
  110. package/dist/validators/commands.js +25 -0
  111. package/package.json +10 -13
  112. package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -68
  113. package/dist/cjs/build/ContextCommandBuilder.js +0 -97
  114. package/dist/cjs/build/EventBuilder.js +0 -44
  115. package/dist/cjs/build/InhibitorBuilder.js +0 -37
  116. package/dist/cjs/build/MessageCommandBuilder.js +0 -100
  117. package/dist/cjs/build/SlashCommandBuilder.js +0 -169
  118. package/dist/cjs/client/XernerxClient.d.ts +0 -28
  119. package/dist/cjs/client/XernerxClient.js +0 -116
  120. package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
  121. package/dist/cjs/handlers/CommandHandler.js +0 -45
  122. package/dist/cjs/handlers/EventHandler.d.ts +0 -13
  123. package/dist/cjs/handlers/EventHandler.js +0 -19
  124. package/dist/cjs/handlers/Handler.d.ts +0 -57
  125. package/dist/cjs/handlers/Handler.js +0 -308
  126. package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
  127. package/dist/cjs/handlers/InhibitorHandler.js +0 -24
  128. package/dist/cjs/main.d.ts +0 -44
  129. package/dist/cjs/main.js +0 -112
  130. package/dist/cjs/models/CommandArguments.js +0 -106
  131. package/dist/cjs/models/Events.js +0 -307
  132. package/dist/cjs/models/Extensions.js +0 -26
  133. package/dist/cjs/tools/XernerxError.d.ts +0 -5
  134. package/dist/cjs/tools/XernerxError.js +0 -11
  135. package/dist/cjs/types/interfaces.d.ts +0 -25
  136. package/dist/cjs/types/interfaces.js +0 -2
  137. package/dist/cjs/types/options.js +0 -2
  138. package/dist/cjs/types/types.d.ts +0 -61
  139. package/dist/cjs/types/types.js +0 -2
  140. package/dist/cjs/utils/ClientUtil.d.ts +0 -25
  141. package/dist/cjs/utils/ClientUtil.js +0 -211
  142. package/dist/cjs/validators/CommandValidations.js +0 -169
  143. package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
  144. package/dist/cjs/validators/InhibitorValidations.js +0 -40
  145. package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -68
  146. package/dist/mjs/build/ContextCommandBuilder.js +0 -97
  147. package/dist/mjs/build/EventBuilder.js +0 -44
  148. package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
  149. package/dist/mjs/build/InhibitorBuilder.js +0 -37
  150. package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
  151. package/dist/mjs/build/MessageCommandBuilder.js +0 -100
  152. package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -65
  153. package/dist/mjs/build/SlashCommandBuilder.js +0 -169
  154. package/dist/mjs/client/XernerxClient.d.ts +0 -28
  155. package/dist/mjs/client/XernerxClient.js +0 -116
  156. package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
  157. package/dist/mjs/handlers/CommandHandler.js +0 -45
  158. package/dist/mjs/handlers/EventHandler.d.ts +0 -13
  159. package/dist/mjs/handlers/EventHandler.js +0 -19
  160. package/dist/mjs/handlers/Handler.d.ts +0 -57
  161. package/dist/mjs/handlers/Handler.js +0 -308
  162. package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
  163. package/dist/mjs/handlers/InhibitorHandler.js +0 -24
  164. package/dist/mjs/main.d.ts +0 -44
  165. package/dist/mjs/main.js +0 -112
  166. package/dist/mjs/models/CommandArguments.d.ts +0 -17
  167. package/dist/mjs/models/Events.d.ts +0 -24
  168. package/dist/mjs/models/Extensions.d.ts +0 -7
  169. package/dist/mjs/models/Extensions.js +0 -26
  170. package/dist/mjs/tools/XernerxError.d.ts +0 -5
  171. package/dist/mjs/tools/XernerxError.js +0 -11
  172. package/dist/mjs/tools/package.d.ts +0 -49
  173. package/dist/mjs/tools/package.js +0 -50
  174. package/dist/mjs/types/enums.d.ts +0 -44
  175. package/dist/mjs/types/enums.js +0 -38
  176. package/dist/mjs/types/interfaces.d.ts +0 -25
  177. package/dist/mjs/types/interfaces.js +0 -2
  178. package/dist/mjs/types/options.d.ts +0 -241
  179. package/dist/mjs/types/options.js +0 -2
  180. package/dist/mjs/types/types.d.ts +0 -61
  181. package/dist/mjs/types/types.js +0 -2
  182. package/dist/mjs/utils/ClientUtil.d.ts +0 -25
  183. package/dist/mjs/utils/ClientUtil.js +0 -211
  184. package/dist/mjs/utils/CommandUtil.d.ts +0 -58
  185. package/dist/mjs/utils/CommandUtil.js +0 -247
  186. package/dist/mjs/validators/CommandValidations.d.ts +0 -12
  187. package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
  188. package/dist/mjs/validators/InhibitorValidations.js +0 -40
  189. /package/dist/{cjs/models → models}/CommandArguments.d.ts +0 -0
  190. /package/dist/{cjs/models → models}/Events.d.ts +0 -0
  191. /package/dist/{cjs/models → models}/Extensions.d.ts +0 -0
  192. /package/dist/{cjs/types → types}/enums.d.ts +0 -0
  193. /package/dist/{cjs/utils → utils}/CommandUtil.d.ts +0 -0
  194. /package/dist/{cjs/validators → validators}/CommandValidations.d.ts +0 -0
@@ -0,0 +1,129 @@
1
+ export async function messageArguments(message, command) {
2
+ const separator = command.separator || ' ',
3
+ content = message.content.split(separator).slice(1);
4
+ let args = {},
5
+ flags = {};
6
+ if (command.flags)
7
+ command.flags.map((flag) => {
8
+ if (!flags) flags = {};
9
+ if (content.includes(flag.match)) flags[flag.name] = true;
10
+ else flags[flag.name] = false;
11
+ const index = content.indexOf(flag.match);
12
+ if (index > 0) content.splice(index, 1);
13
+ });
14
+ if (command.args)
15
+ for (const argument of command.args) {
16
+ const element = content.at(0) || null;
17
+ if (!element) {
18
+ if (typeof argument.default === 'function') args[argument.name] = argument.default(message);
19
+ args[argument.name] = argument.default || null;
20
+ continue;
21
+ }
22
+ if (argument.type === 'option') argument.match?.includes(element) ? (args[argument.name] = element) : (args[argument.name] = null);
23
+ if (argument.type === 'number') args[argument.name] = parseInt(element);
24
+ if (argument.type === 'integer') args[argument.name] = parseInt(element);
25
+ if (argument.type === 'boolean') args[argument.name] = element === 'true' ? true : false;
26
+ if (argument.type === 'confirm') args[argument.name] = element === 'yes' ? 'yes' : 'no';
27
+ if (argument.type === 'string') args[argument.name] = element;
28
+ if (argument.type === 'channel') {
29
+ try {
30
+ const channel = await message.client.channels.fetch(element);
31
+ args[argument.name] = channel;
32
+ } catch (e) {
33
+ args[argument.name] = null;
34
+ }
35
+ }
36
+ if (argument.type === 'guild') {
37
+ try {
38
+ const guild = await message.client.guilds.fetch(element);
39
+ args[argument.name] = guild;
40
+ } catch (e) {
41
+ args[argument.name] = null;
42
+ }
43
+ }
44
+ if (argument.type === 'mentionable') {
45
+ (
46
+ await Promise.all(
47
+ [message.guild?.roles, message.client.users, message.client.guilds, message.client.channels, message.guild?.members, message.channel.messages].map((req) =>
48
+ req
49
+ ? req
50
+ .fetch(element)
51
+ .then((r) => r)
52
+ .catch(() => null)
53
+ : null
54
+ )
55
+ )
56
+ ).map((mentionable) => {
57
+ if (!args) args = {};
58
+ if (mentionable) return (args[argument.name] = mentionable);
59
+ else args[argument.name] = null;
60
+ });
61
+ }
62
+ if (argument.type === 'role') {
63
+ try {
64
+ const role = await message.guild?.roles.fetch(element);
65
+ args[argument.name] = role;
66
+ } catch (e) {
67
+ args[argument.name] = null;
68
+ }
69
+ }
70
+ if (argument.type === 'user') {
71
+ try {
72
+ const user = await message.client.users.fetch(element);
73
+ args[argument.name] = user;
74
+ } catch (e) {
75
+ args[argument.name] = null;
76
+ }
77
+ }
78
+ if (argument.type === 'member') {
79
+ try {
80
+ const member = await message.guild?.members.fetch(element);
81
+ args[argument.name] = member;
82
+ } catch (e) {
83
+ args[argument.name] = null;
84
+ }
85
+ }
86
+ if (argument.type === 'message') {
87
+ try {
88
+ const msg = await message.channel?.messages.fetch(element);
89
+ args[argument.name] = msg;
90
+ } catch (e) {
91
+ args[argument.name] = null;
92
+ }
93
+ }
94
+ if (argument.type === 'list') {
95
+ let separator = String(argument.separator) || ',';
96
+ if (separator.startsWith('/') && separator.endsWith('/')) separator = separator.replace(/^\/|\/$/gim, '');
97
+ const items = content.join(' ').split(new RegExp(' *' + separator + ' *', 'gi'));
98
+ if (!argument.content) args[argument.name] = items;
99
+ else {
100
+ const contents = argument.content.map((content) => content.toLowerCase()),
101
+ itemList = [];
102
+ items.map((item) => (contents.includes(item.toLowerCase()) ? itemList.push(argument.content?.at(contents.indexOf(item.toLowerCase()))) : null));
103
+ args[argument.name] = itemList;
104
+ break;
105
+ }
106
+ }
107
+ if (argument.type === 'rest') {
108
+ args[argument.name] = content.join(separator);
109
+ break;
110
+ }
111
+ content.splice(0, 1);
112
+ }
113
+ if (!command.flags) flags = null;
114
+ if (!command.args) args = null;
115
+ return { args, flags };
116
+ }
117
+ export async function interactionArguments(interaction, command) {
118
+ const options = {};
119
+ let args = interaction?.options?._hoistedOptions,
120
+ group = interaction?.options?._group,
121
+ subcommand = interaction?.options?._subcommand;
122
+ if (interaction.options._hoistedOptions) {
123
+ for (const option of interaction.options._hoistedOptions) {
124
+ options[option.name] = option.member || option.channel || option.user || option.role || option.value;
125
+ }
126
+ args = options;
127
+ }
128
+ return { args, group, subcommand };
129
+ }
@@ -1,7 +1,4 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.messageArguments = exports.InteractionArguments = void 0;
4
- class InteractionArguments {
1
+ export class InteractionArguments {
5
2
  interaction;
6
3
  constructor(interaction) {
7
4
  this.interaction = interaction;
@@ -22,8 +19,7 @@ class InteractionArguments {
22
19
  return options;
23
20
  }
24
21
  }
25
- exports.InteractionArguments = InteractionArguments;
26
- async function messageArguments(message, command) {
22
+ export async function messageArguments(message, command) {
27
23
  let args = { flags: {} },
28
24
  separator = command.separator || ' ',
29
25
  i = 0;
@@ -103,4 +99,3 @@ async function messageArguments(message, command) {
103
99
  }
104
100
  return args;
105
101
  }
106
- exports.messageArguments = messageArguments;
@@ -1,18 +1,11 @@
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
- class MessageCommandEvents {
1
+ import { GatewayVersion, InteractionType, REST, Routes } from 'discord.js';
2
+ import { InteractionCommandUtil, MessageCommandUtil } from '../utils/CommandUtil.js';
3
+ import { InteractionArguments, messageArguments } from './CommandArguments.js';
4
+ import commandValidation from '../validators/CommandValidations.js';
5
+ import { Style } from 'dumfunctions';
6
+ import { InhibitorValidation } from '../validators/InhibitorValidations.js';
7
+ import User from './XernerxUser.js';
8
+ export class MessageCommandEvents {
16
9
  client;
17
10
  constructor(client) {
18
11
  this.client = client;
@@ -22,8 +15,8 @@ class MessageCommandEvents {
22
15
  if (!message.author.bot) {
23
16
  let command = undefined,
24
17
  px = undefined;
25
- message.author.isOwner = this.client.util.isOwner(message.author.id);
26
- message.util = new CommandUtil_js_1.MessageCommandUtil(this.client, message);
18
+ message.author = await User(message);
19
+ message.util = new MessageCommandUtil(this.client, message);
27
20
  const commands = this.client.commands.message;
28
21
  commands
29
22
  .filter((c) => !c.regex)
@@ -58,11 +51,11 @@ class MessageCommandEvents {
58
51
  ) {
59
52
  try {
60
53
  if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
61
- const inhibitor = new InhibitorValidations_js_1.InhibitorValidation(this.client, message, command);
62
- if ((0, CommandValidations_js_1.default)(message, cmd, this.client)) return;
54
+ const inhibitor = new InhibitorValidation(this.client, message, command);
55
+ if (commandValidation(message, cmd, this.client)) return;
63
56
  if (await inhibitor.inhibit()) return;
64
- if (cmd.conditions && (await cmd.conditions(message, await (0, CommandArguments_js_1.messageArguments)(message, cmd)))) return;
65
- await cmd.exec(message, await (0, CommandArguments_js_1.messageArguments)(message, cmd));
57
+ if (cmd.conditions && (await cmd.conditions(message, await messageArguments(message, cmd)))) return;
58
+ await cmd.exec(message, await messageArguments(message, cmd));
66
59
  this.client.emit('commandRun', message, cmd);
67
60
  } catch (error) {
68
61
  return this.client.emit('commandError', message, error, cmd);
@@ -78,8 +71,8 @@ class MessageCommandEvents {
78
71
  if (!message.author?.bot) {
79
72
  let command = undefined,
80
73
  px = undefined;
81
- if (message.author) message.author.isOwner = this.client.util.isOwner(message.author.id);
82
- message.util = new CommandUtil_js_1.MessageCommandUtil(this.client, message);
74
+ message.author = await User(message);
75
+ message.util = new MessageCommandUtil(this.client, message);
83
76
  const commands = this.client.commands.message;
84
77
  commands
85
78
  .filter((c) => !c.regex)
@@ -115,11 +108,11 @@ class MessageCommandEvents {
115
108
  try {
116
109
  if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
117
110
  message = message;
118
- const inhibitor = new InhibitorValidations_js_1.InhibitorValidation(this.client, message, command);
119
- if ((0, CommandValidations_js_1.default)(message, cmd, this.client)) return;
111
+ const inhibitor = new InhibitorValidation(this.client, message, command);
112
+ if (commandValidation(message, cmd, this.client)) return;
120
113
  if (await inhibitor.inhibit()) return;
121
- if (cmd.conditions && (await cmd.conditions(message, await (0, CommandArguments_js_1.messageArguments)(message, cmd)))) return;
122
- await cmd.exec(message, await (0, CommandArguments_js_1.messageArguments)(message, cmd));
114
+ if (cmd.conditions && (await cmd.conditions(message, await messageArguments(message, cmd)))) return;
115
+ await cmd.exec(message, await messageArguments(message, cmd));
123
116
  this.client.emit('commandRun', message, cmd);
124
117
  } catch (error) {
125
118
  return this.client.emit('commandError', message, error, cmd);
@@ -134,6 +127,7 @@ class MessageCommandEvents {
134
127
  if (this.client.cache.messages.has(message.id) && this.client.handlerOptions.message?.handleDeletes) {
135
128
  try {
136
129
  if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
130
+ message.author = await User(message);
137
131
  const msg = this.client.cache.messages.get(message.id);
138
132
  const response = await message.channel.messages.fetch(msg?.response);
139
133
  await response.delete();
@@ -144,24 +138,23 @@ class MessageCommandEvents {
144
138
  });
145
139
  }
146
140
  }
147
- exports.MessageCommandEvents = MessageCommandEvents;
148
- class SlashCommandEvents {
141
+ export class SlashCommandEvents {
149
142
  client;
150
143
  constructor(client) {
151
144
  this.client = client;
152
145
  }
153
146
  slashCreate() {
154
147
  this.client.on('interactionCreate', async (interaction) => {
155
- interaction.util = new CommandUtil_js_1.InteractionCommandUtil(this.client, interaction);
156
- interaction.user.isOwner = this.client.util.isOwner(interaction.user.id);
157
- if (interaction.type === discord_js_1.InteractionType.ApplicationCommand) {
148
+ interaction.util = new InteractionCommandUtil(this.client, interaction);
149
+ interaction.author = await User(interaction);
150
+ if (interaction.type === InteractionType.ApplicationCommand) {
158
151
  if (this.client.commands.slash.has(interaction.commandName)) {
159
152
  let command = this.client.commands.slash.get(interaction.commandName);
160
- const argumentsInfo = new CommandArguments_js_1.InteractionArguments(interaction);
153
+ const argumentsInfo = new InteractionArguments(interaction);
161
154
  try {
162
- const inhibitor = new InhibitorValidations_js_1.InhibitorValidation(this.client, interaction, command);
155
+ const inhibitor = new InhibitorValidation(this.client, interaction, command);
163
156
  if (await inhibitor.inhibit()) return;
164
- if ((0, CommandValidations_js_1.default)(interaction, command, this.client)) return;
157
+ if (commandValidation(interaction, command, this.client)) return;
165
158
  if (command.defer?.reply !== false && this.client.handlerOptions.slash?.defer?.reply)
166
159
  await interaction.deferReply({
167
160
  ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral,
@@ -195,22 +188,21 @@ class SlashCommandEvents {
195
188
  });
196
189
  }
197
190
  }
198
- exports.SlashCommandEvents = SlashCommandEvents;
199
- class ContextCommandEvents {
191
+ export class ContextCommandEvents {
200
192
  client;
201
193
  constructor(client) {
202
194
  this.client = client;
203
195
  }
204
196
  contextCreate() {
205
197
  this.client.on('interactionCreate', async (interaction) => {
206
- interaction.util = new CommandUtil_js_1.InteractionCommandUtil(this.client, interaction);
207
- interaction.user.isOwner = this.client.util.isOwner(interaction.user.id);
208
- if (interaction.type === discord_js_1.InteractionType.ApplicationCommand) {
198
+ interaction.util = new InteractionCommandUtil(this.client, interaction);
199
+ interaction.author = await User(interaction);
200
+ if (interaction.type === InteractionType.ApplicationCommand) {
209
201
  if (this.client.commands.context.has(interaction.commandName)) {
210
202
  let command = this.client.commands.context.get(interaction.commandName);
211
203
  try {
212
- const inhibitor = new InhibitorValidations_js_1.InhibitorValidation(this.client, interaction, command);
213
- if ((0, CommandValidations_js_1.default)(interaction, command, this.client)) return;
204
+ const inhibitor = new InhibitorValidation(this.client, interaction, command);
205
+ if (commandValidation(interaction, command, this.client)) return;
214
206
  if (await inhibitor.inhibit()) return;
215
207
  if (command.conditions && (await command.conditions(interaction))) return;
216
208
  if (command.defer?.reply !== false && this.client.handlerOptions.context?.defer?.reply)
@@ -236,8 +228,7 @@ class ContextCommandEvents {
236
228
  });
237
229
  }
238
230
  }
239
- exports.ContextCommandEvents = ContextCommandEvents;
240
- class CommandsDeploy {
231
+ export class CommandsDeploy {
241
232
  client;
242
233
  constructor(client) {
243
234
  this.client = client;
@@ -261,11 +252,11 @@ class CommandsDeploy {
261
252
  if (global.slash && global.context) {
262
253
  if (guild.slash !== guild.context)
263
254
  console.info(
264
- dumfunctions_1.Style.log(
255
+ Style.log(
265
256
  `Xernerx | Warning: slash and context commands are both set to global, but don't have a matching guildId, using ${
266
257
  (await this.client.guilds.fetch(this.client.handlerOptions.slash?.guildId)).name
267
258
  }!`,
268
- { color: dumfunctions_1.Style.TextColor.Red }
259
+ { color: Style.TextColor.Red }
269
260
  )
270
261
  );
271
262
  this.put('global', guild.slash, [...contextCommands, ...slashCommands]);
@@ -282,26 +273,25 @@ class CommandsDeploy {
282
273
  }
283
274
  if (this.client.handlerOptions.context?.logging || this.client.handlerOptions.slash?.logging)
284
275
  console.info(
285
- dumfunctions_1.Style.log(
276
+ Style.log(
286
277
  `Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? 'globally' : 'locally'} and ${contextCommands.length} context commands ${
287
278
  global.context ? 'globally' : 'locally'
288
279
  }.`,
289
- { color: dumfunctions_1.Style.TextColor.Purple }
280
+ { color: Style.TextColor.Purple }
290
281
  )
291
282
  );
292
283
  } catch (error) {
293
284
  console.error(
294
- dumfunctions_1.Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
295
- color: dumfunctions_1.Style.BackgroundColor.Red,
285
+ Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
286
+ color: Style.BackgroundColor.Red,
296
287
  })
297
288
  );
298
289
  }
299
290
  });
300
291
  }
301
292
  put(type, guild, body) {
302
- const rest = new discord_js_1.REST({ version: discord_js_1.GatewayVersion }).setToken(this.client.token);
303
- if (type === 'guild') rest.put(discord_js_1.Routes.applicationGuildCommands(this.client.user?.id, guild), { body });
304
- else rest.put(discord_js_1.Routes.applicationCommands(this.client.user?.id), { body });
293
+ const rest = new REST({ version: GatewayVersion }).setToken(this.client.token);
294
+ if (type === 'guild') rest.put(Routes.applicationGuildCommands(this.client.user?.id, guild), { body });
295
+ else rest.put(Routes.applicationCommands(this.client.user?.id), { body });
305
296
  }
306
297
  }
307
- exports.CommandsDeploy = CommandsDeploy;
@@ -0,0 +1,23 @@
1
+ import { Style } from 'dumfunctions';
2
+ export default class Extensions {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ async load(extensions, logging = false) {
8
+ const exts = [];
9
+ extensions.map((extension) => {
10
+ try {
11
+ this.client.extensions[extension.name] = extension;
12
+ exts.push(extension.name);
13
+ } catch (error) {
14
+ console.error(
15
+ Style.log(`Xernerx | An error occurred trying to load ${extension.name}, error: <${error}>`, {
16
+ color: Style.BackgroundColor.Red,
17
+ })
18
+ );
19
+ }
20
+ });
21
+ if (logging) console.info(Style.log(`Xernerx | Loaded ${exts.length} extensions: ${exts.join(', ')}`, { color: Style.TextColor.Cyan }));
22
+ }
23
+ }
@@ -0,0 +1,2 @@
1
+ import { XernerxUser } from '../types/types.js';
2
+ export default function XernerxUser(interaction: any): Promise<XernerxUser>;
@@ -0,0 +1,9 @@
1
+ import { hasVoted } from 'dbl-sdk';
2
+ export default async function XernerxUser(interaction) {
3
+ const user = interaction.user || interaction.author;
4
+ user.owner = interaction.client.util.isOwner(user.id);
5
+ user.voter = interaction.client.handlerOptions?.webhook?.topgg?.token
6
+ ? await hasVoted(user.id, interaction.client.user.id, interaction.client.handlerOptions.webhook.topgg.token, 'top.gg')
7
+ : false;
8
+ return user;
9
+ }
@@ -0,0 +1,6 @@
1
+ export default class XernerxError {
2
+ name: string;
3
+ message: string | null;
4
+ stack: {} | undefined;
5
+ constructor(message?: string, error?: Error | unknown);
6
+ }
@@ -0,0 +1,10 @@
1
+ export default class XernerxError {
2
+ name;
3
+ message;
4
+ stack;
5
+ constructor(message, error) {
6
+ this.name = 'XernerxError';
7
+ this.message = message || null;
8
+ this.stack = error || new Error().stack;
9
+ }
10
+ }
@@ -0,0 +1,13 @@
1
+ import XernerxError from './XernerxError.js';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ export default class XernerxLog {
4
+ private readonly client;
5
+ private readonly errorLog;
6
+ private readonly infoLog;
7
+ private readonly readyLog;
8
+ constructor(client: XernerxClient);
9
+ info(message: string, force?: boolean): void | null;
10
+ warn(message: string): void | null;
11
+ error(message: string, error?: XernerxError | unknown): void | null;
12
+ ready(): void;
13
+ }
@@ -0,0 +1,30 @@
1
+ import { Style } from 'dumfunctions';
2
+ export default class XernerxLog {
3
+ client;
4
+ errorLog;
5
+ infoLog;
6
+ readyLog;
7
+ constructor(client) {
8
+ this.client = client;
9
+ this.errorLog = client.settings.log?.error;
10
+ this.infoLog = client.settings.log?.info;
11
+ this.readyLog = client.settings.log?.ready;
12
+ }
13
+ info(message, force = false) {
14
+ return this.infoLog || force ? console.info(`${Style.log('✔️ | Xernerx', { color: Style.TextColor.Purple })} | ${message}`) : null;
15
+ }
16
+ warn(message) {
17
+ return this.infoLog ? console.warn(`${Style.log('⚠️ | Xernerx', { color: Style.TextColor.Yellow })} | ${message}`) : null;
18
+ }
19
+ error(message, error) {
20
+ return this.errorLog ? console.error(`${Style.log('❗ | Xernerx', { color: Style.TextColor.Red })} | ${message}${error ? ` | ${error.stack}` : ''}`) : null;
21
+ }
22
+ ready() {
23
+ this.client.prependOnceListener('ready', async (synced) =>
24
+ this.info(
25
+ `${synced.user.tag} is now online, watching ${(await this.client.guilds.fetch()).size} guilds, using ${await this.client.guilds.fetch(this.client.settings.local)} as local guild.`,
26
+ this.readyLog
27
+ )
28
+ );
29
+ }
30
+ }
@@ -0,0 +1,6 @@
1
+ export default class XernerxError {
2
+ name: string;
3
+ message: string | null;
4
+ error: Error;
5
+ constructor(message?: string, error?: Error);
6
+ }
@@ -0,0 +1,10 @@
1
+ export default class XernerxError {
2
+ name;
3
+ message;
4
+ error;
5
+ constructor(message, error) {
6
+ this.name = 'XernerxError';
7
+ this.message = message || null;
8
+ this.error = error || new Error();
9
+ }
10
+ }
@@ -0,0 +1,4 @@
1
+ export default class XernerxLog {
2
+ info(message: string): void;
3
+ error(message: string): void;
4
+ }
@@ -0,0 +1,4 @@
1
+ export default class XernerxLog {
2
+ info(message) {}
3
+ error(message) {}
4
+ }
@@ -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;
@@ -35,6 +31,7 @@ declare const _default: {
35
31
  };
36
32
  dependencies: {
37
33
  '@sapphire/shapeshift': string;
34
+ 'dbl-sdk': string;
38
35
  'discord.js': string;
39
36
  dumfunctions: string;
40
37
  'xernerx-extension-builder': string;
@@ -42,7 +39,6 @@ declare const _default: {
42
39
  };
43
40
  devDependencies: {
44
41
  prettier: string;
45
- tsup: string;
46
42
  typescript: string;
47
43
  };
48
44
  };
@@ -1,23 +1,14 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.default = {
1
+ export default {
4
2
  name: 'xernerx',
5
- version: '3.5.1',
6
- type: 'module',
3
+ version: '3.6.0',
7
4
  description: 'A bot framework for discord.js.',
8
- main: 'dist/main.js',
5
+ main: 'dist/cjs/main.js',
6
+ module: 'dist/mjs/main.js',
9
7
  keywords: ['discord.js', 'discord', 'framework', 'mjs', 'esm', 'cjs', 'ts'],
10
8
  author: 'Dummi',
11
9
  license: 'MIT',
12
10
  homepage: 'https://xernerx.github.io/xernerx/home.html',
13
11
  packageManager: 'npm@8.5.5',
14
- exports: {
15
- import: './dist/main.js',
16
- require: './dist/main.cjs',
17
- types: './types',
18
- node: null,
19
- default: null,
20
- },
21
12
  scripts: {
22
13
  start: 'npm i && npm fund && npm audit fix --force && npm link && tsc -w',
23
14
  patch: 'npm run write && git add . && npm run commit && npm version patch && npm publish && git push',
@@ -25,8 +16,11 @@ exports.default = {
25
16
  major: 'npm run write && git add . && npm run commit && npm version major && npm publish && git push',
26
17
  site: 'git add docs && npm run commit && git push',
27
18
  commit: 'node ../.scripts/commit.js',
28
- write: 'npm run build && node ../.scripts/rewritePackage.js ',
29
- build: 'tsc && npx tsup src/main.ts && npx prettier --write src',
19
+ write: 'npm run build && npm run format && node ../.scripts/rewritePackage.js ',
20
+ format: 'npx prettier --write src dist',
21
+ build: 'npm run build:esm && npm run build:cjs && npm run format',
22
+ 'build:esm': 'tsc',
23
+ 'build:cjs': 'tsc --module CommonJS --outDir dist/cjs',
30
24
  },
31
25
  repository: {
32
26
  type: 'git',
@@ -37,14 +31,14 @@ exports.default = {
37
31
  },
38
32
  dependencies: {
39
33
  '@sapphire/shapeshift': '^3.8.1',
34
+ 'dbl-sdk': '^1.2.0',
40
35
  'discord.js': '^14.7.1',
41
- dumfunctions: '^2.1.1',
42
- 'xernerx-extension-builder': '^0.0.5',
36
+ dumfunctions: '^2.1.2',
37
+ 'xernerx-extension-builder': '^0.0.8',
43
38
  zod: '^3.20.6',
44
39
  },
45
40
  devDependencies: {
46
41
  prettier: '^2.8.4',
47
- tsup: '^6.6.0',
48
42
  typescript: '^4.9.5',
49
43
  },
50
44
  };
@@ -1,7 +1,4 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.EventEmitterType = exports.ContextCommandType = exports.CommandType = exports.InhibitorType = void 0;
4
- var InhibitorType;
1
+ export var InhibitorType;
5
2
  (function (InhibitorType) {
6
3
  InhibitorType['Member'] = 'Member';
7
4
  InhibitorType['User'] = 'User';
@@ -13,8 +10,8 @@ var InhibitorType;
13
10
  InhibitorType['Message'] = 'Message';
14
11
  InhibitorType['Interaction'] = 'Interaction';
15
12
  InhibitorType['Channel'] = 'Channel';
16
- })((InhibitorType = exports.InhibitorType || (exports.InhibitorType = {})));
17
- var CommandType;
13
+ })((InhibitorType = InhibitorType || (InhibitorType = {})));
14
+ export var CommandType;
18
15
  (function (CommandType) {
19
16
  CommandType['Message'] = 'MessageCommand';
20
17
  CommandType['Slash'] = 'SlashCommand';
@@ -24,15 +21,15 @@ var CommandType;
24
21
  CommandType['MessageCommand'] = 'MessageCommand';
25
22
  CommandType['SlashCommand'] = 'SlashCommand';
26
23
  CommandType['ContextCommand'] = 'ContextCommand';
27
- })((CommandType = exports.CommandType || (exports.CommandType = {})));
28
- var ContextCommandType;
24
+ })((CommandType = CommandType || (CommandType = {})));
25
+ export var ContextCommandType;
29
26
  (function (ContextCommandType) {
30
27
  ContextCommandType[(ContextCommandType['Message'] = 3)] = 'Message';
31
28
  ContextCommandType[(ContextCommandType['User'] = 2)] = 'User';
32
- })((ContextCommandType = exports.ContextCommandType || (exports.ContextCommandType = {})));
33
- var EventEmitterType;
29
+ })((ContextCommandType = ContextCommandType || (ContextCommandType = {})));
30
+ export var EventEmitterType;
34
31
  (function (EventEmitterType) {
35
32
  EventEmitterType['Client'] = 'client';
36
33
  EventEmitterType['Rest'] = 'rest';
37
34
  EventEmitterType['Process'] = 'process';
38
- })((EventEmitterType = exports.EventEmitterType || (exports.EventEmitterType = {})));
35
+ })((EventEmitterType = EventEmitterType || (EventEmitterType = {})));