xernerx 3.6.0 → 4.0.1

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 (201) 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/{cjs/models → models}/CommandArguments.js +2 -7
  70. package/dist/{mjs/models → models}/Events.js +44 -56
  71. package/dist/models/Extensions.js +23 -0
  72. package/dist/models/XernerxUser.js +9 -0
  73. package/dist/tools/XernerxError.d.ts +6 -0
  74. package/dist/tools/XernerxError.js +10 -0
  75. package/dist/tools/XernerxLog.d.ts +13 -0
  76. package/dist/tools/XernerxLog.js +30 -0
  77. package/dist/tools/classes.d.ts +6 -0
  78. package/dist/tools/classes.js +10 -0
  79. package/dist/tools/loggers.d.ts +4 -0
  80. package/dist/tools/loggers.js +4 -0
  81. package/dist/{mjs/tools → tools}/package.d.ts +1 -4
  82. package/dist/{cjs/tools → tools}/package.js +11 -16
  83. package/dist/{cjs/types → types}/enums.js +8 -11
  84. package/dist/types/extenders.d.ts +23 -0
  85. package/dist/types/extenders.js +1 -0
  86. package/dist/types/interfaces.d.ts +224 -0
  87. package/dist/types/interfaces.js +1 -0
  88. package/dist/types/options.js +1 -0
  89. package/dist/types/types.d.ts +181 -0
  90. package/dist/types/types.js +1 -0
  91. package/dist/utils/ClientUtil.d.ts +6 -0
  92. package/dist/utils/ClientUtil.js +7 -0
  93. package/dist/{cjs/utils → utils}/CommandUtil.js +14 -29
  94. package/dist/utils/InteractionArguments.d.ts +1 -0
  95. package/dist/utils/InteractionArguments.js +1 -0
  96. package/dist/utils/InteractionUtil.d.ts +10 -0
  97. package/dist/utils/InteractionUtil.js +15 -0
  98. package/dist/utils/MessageUtil.d.ts +11 -0
  99. package/dist/utils/MessageUtil.js +42 -0
  100. package/dist/utils/Util.d.ts +5 -0
  101. package/dist/utils/Util.js +6 -0
  102. package/dist/{mjs/validators → validators}/CommandValidations.js +10 -13
  103. package/dist/validators/InhibitorValidations.d.ts +18 -0
  104. package/dist/validators/InhibitorValidations.js +34 -0
  105. package/dist/validators/commandValidation.d.ts +6 -0
  106. package/dist/validators/commandValidation.js +48 -0
  107. package/dist/validators/commands.d.ts +4 -0
  108. package/dist/validators/commands.js +25 -0
  109. package/package.json +10 -13
  110. package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -63
  111. package/dist/cjs/build/ContextCommandBuilder.js +0 -97
  112. package/dist/cjs/build/EventBuilder.js +0 -44
  113. package/dist/cjs/build/InhibitorBuilder.js +0 -37
  114. package/dist/cjs/build/MessageCommandBuilder.js +0 -100
  115. package/dist/cjs/build/SlashCommandBuilder.js +0 -169
  116. package/dist/cjs/client/XernerxClient.d.ts +0 -29
  117. package/dist/cjs/client/XernerxClient.js +0 -120
  118. package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
  119. package/dist/cjs/handlers/CommandHandler.js +0 -45
  120. package/dist/cjs/handlers/EventHandler.d.ts +0 -13
  121. package/dist/cjs/handlers/EventHandler.js +0 -19
  122. package/dist/cjs/handlers/Handler.d.ts +0 -57
  123. package/dist/cjs/handlers/Handler.js +0 -308
  124. package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
  125. package/dist/cjs/handlers/InhibitorHandler.js +0 -24
  126. package/dist/cjs/handlers/WebhookHandler.d.ts +0 -7
  127. package/dist/cjs/handlers/WebhookHandler.js +0 -23
  128. package/dist/cjs/main.d.ts +0 -44
  129. package/dist/cjs/main.js +0 -112
  130. package/dist/cjs/models/Events.js +0 -309
  131. package/dist/cjs/models/Extensions.js +0 -26
  132. package/dist/cjs/models/XernerxUser.js +0 -12
  133. package/dist/cjs/tools/XernerxError.d.ts +0 -5
  134. package/dist/cjs/tools/XernerxError.js +0 -11
  135. package/dist/cjs/tools/package.d.ts +0 -44
  136. package/dist/cjs/types/interfaces.d.ts +0 -27
  137. package/dist/cjs/types/interfaces.js +0 -2
  138. package/dist/cjs/types/options.js +0 -2
  139. package/dist/cjs/types/types.d.ts +0 -62
  140. package/dist/cjs/types/types.js +0 -2
  141. package/dist/cjs/utils/ClientUtil.d.ts +0 -26
  142. package/dist/cjs/utils/ClientUtil.js +0 -211
  143. package/dist/cjs/validators/CommandValidations.js +0 -169
  144. package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
  145. package/dist/cjs/validators/InhibitorValidations.js +0 -40
  146. package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -63
  147. package/dist/mjs/build/ContextCommandBuilder.js +0 -97
  148. package/dist/mjs/build/EventBuilder.js +0 -44
  149. package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
  150. package/dist/mjs/build/InhibitorBuilder.js +0 -37
  151. package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
  152. package/dist/mjs/build/MessageCommandBuilder.js +0 -100
  153. package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -65
  154. package/dist/mjs/build/SlashCommandBuilder.js +0 -169
  155. package/dist/mjs/client/XernerxClient.d.ts +0 -29
  156. package/dist/mjs/client/XernerxClient.js +0 -120
  157. package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
  158. package/dist/mjs/handlers/CommandHandler.js +0 -45
  159. package/dist/mjs/handlers/EventHandler.d.ts +0 -13
  160. package/dist/mjs/handlers/EventHandler.js +0 -19
  161. package/dist/mjs/handlers/Handler.d.ts +0 -57
  162. package/dist/mjs/handlers/Handler.js +0 -308
  163. package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
  164. package/dist/mjs/handlers/InhibitorHandler.js +0 -24
  165. package/dist/mjs/handlers/WebhookHandler.d.ts +0 -7
  166. package/dist/mjs/handlers/WebhookHandler.js +0 -23
  167. package/dist/mjs/main.d.ts +0 -44
  168. package/dist/mjs/main.js +0 -112
  169. package/dist/mjs/models/CommandArguments.d.ts +0 -17
  170. package/dist/mjs/models/CommandArguments.js +0 -106
  171. package/dist/mjs/models/Events.d.ts +0 -24
  172. package/dist/mjs/models/Extensions.d.ts +0 -7
  173. package/dist/mjs/models/Extensions.js +0 -26
  174. package/dist/mjs/models/XernerxUser.d.ts +0 -2
  175. package/dist/mjs/models/XernerxUser.js +0 -12
  176. package/dist/mjs/tools/XernerxError.d.ts +0 -5
  177. package/dist/mjs/tools/XernerxError.js +0 -11
  178. package/dist/mjs/tools/package.js +0 -45
  179. package/dist/mjs/types/enums.d.ts +0 -44
  180. package/dist/mjs/types/enums.js +0 -38
  181. package/dist/mjs/types/interfaces.d.ts +0 -27
  182. package/dist/mjs/types/interfaces.js +0 -2
  183. package/dist/mjs/types/options.d.ts +0 -254
  184. package/dist/mjs/types/options.js +0 -2
  185. package/dist/mjs/types/types.d.ts +0 -62
  186. package/dist/mjs/types/types.js +0 -2
  187. package/dist/mjs/utils/ClientUtil.d.ts +0 -26
  188. package/dist/mjs/utils/ClientUtil.js +0 -211
  189. package/dist/mjs/utils/CommandUtil.d.ts +0 -58
  190. package/dist/mjs/utils/CommandUtil.js +0 -247
  191. package/dist/mjs/validators/CommandValidations.d.ts +0 -12
  192. package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
  193. package/dist/mjs/validators/InhibitorValidations.js +0 -40
  194. /package/dist/{cjs/models → models}/CommandArguments.d.ts +0 -0
  195. /package/dist/{cjs/models → models}/Events.d.ts +0 -0
  196. /package/dist/{cjs/models → models}/Extensions.d.ts +0 -0
  197. /package/dist/{cjs/models → models}/XernerxUser.d.ts +0 -0
  198. /package/dist/{cjs/types → types}/enums.d.ts +0 -0
  199. /package/dist/{cjs/types → types}/options.d.ts +0 -0
  200. /package/dist/{cjs/utils → utils}/CommandUtil.d.ts +0 -0
  201. /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,19 +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
- const XernerxUser_js_1 = __importDefault(require('./XernerxUser.js'));
16
- 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 {
17
9
  client;
18
10
  constructor(client) {
19
11
  this.client = client;
@@ -23,8 +15,8 @@ class MessageCommandEvents {
23
15
  if (!message.author.bot) {
24
16
  let command = undefined,
25
17
  px = undefined;
26
- message.author = await (0, XernerxUser_js_1.default)(message);
27
- message.util = new CommandUtil_js_1.MessageCommandUtil(this.client, message);
18
+ message.author = await User(message);
19
+ message.util = new MessageCommandUtil(this.client, message);
28
20
  const commands = this.client.commands.message;
29
21
  commands
30
22
  .filter((c) => !c.regex)
@@ -59,11 +51,11 @@ class MessageCommandEvents {
59
51
  ) {
60
52
  try {
61
53
  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;
54
+ const inhibitor = new InhibitorValidation(this.client, message, command);
55
+ if (commandValidation(message, cmd, this.client)) return;
64
56
  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));
57
+ if (cmd.conditions && (await cmd.conditions(message, await messageArguments(message, cmd)))) return;
58
+ await cmd.exec(message, await messageArguments(message, cmd));
67
59
  this.client.emit('commandRun', message, cmd);
68
60
  } catch (error) {
69
61
  return this.client.emit('commandError', message, error, cmd);
@@ -79,8 +71,8 @@ class MessageCommandEvents {
79
71
  if (!message.author?.bot) {
80
72
  let command = undefined,
81
73
  px = undefined;
82
- message.author = await (0, XernerxUser_js_1.default)(message);
83
- message.util = new CommandUtil_js_1.MessageCommandUtil(this.client, message);
74
+ message.author = await User(message);
75
+ message.util = new MessageCommandUtil(this.client, message);
84
76
  const commands = this.client.commands.message;
85
77
  commands
86
78
  .filter((c) => !c.regex)
@@ -116,11 +108,11 @@ class MessageCommandEvents {
116
108
  try {
117
109
  if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
118
110
  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;
111
+ const inhibitor = new InhibitorValidation(this.client, message, command);
112
+ if (commandValidation(message, cmd, this.client)) return;
121
113
  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));
114
+ if (cmd.conditions && (await cmd.conditions(message, await messageArguments(message, cmd)))) return;
115
+ await cmd.exec(message, await messageArguments(message, cmd));
124
116
  this.client.emit('commandRun', message, cmd);
125
117
  } catch (error) {
126
118
  return this.client.emit('commandError', message, error, cmd);
@@ -135,7 +127,7 @@ class MessageCommandEvents {
135
127
  if (this.client.cache.messages.has(message.id) && this.client.handlerOptions.message?.handleDeletes) {
136
128
  try {
137
129
  if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
138
- message.author = await (0, XernerxUser_js_1.default)(message);
130
+ message.author = await User(message);
139
131
  const msg = this.client.cache.messages.get(message.id);
140
132
  const response = await message.channel.messages.fetch(msg?.response);
141
133
  await response.delete();
@@ -146,24 +138,23 @@ class MessageCommandEvents {
146
138
  });
147
139
  }
148
140
  }
149
- exports.MessageCommandEvents = MessageCommandEvents;
150
- class SlashCommandEvents {
141
+ export class SlashCommandEvents {
151
142
  client;
152
143
  constructor(client) {
153
144
  this.client = client;
154
145
  }
155
146
  slashCreate() {
156
147
  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) {
148
+ interaction.util = new InteractionCommandUtil(this.client, interaction);
149
+ interaction.author = await User(interaction);
150
+ if (interaction.type === InteractionType.ApplicationCommand) {
160
151
  if (this.client.commands.slash.has(interaction.commandName)) {
161
152
  let command = this.client.commands.slash.get(interaction.commandName);
162
- const argumentsInfo = new CommandArguments_js_1.InteractionArguments(interaction);
153
+ const argumentsInfo = new InteractionArguments(interaction);
163
154
  try {
164
- const inhibitor = new InhibitorValidations_js_1.InhibitorValidation(this.client, interaction, command);
155
+ const inhibitor = new InhibitorValidation(this.client, interaction, command);
165
156
  if (await inhibitor.inhibit()) return;
166
- if ((0, CommandValidations_js_1.default)(interaction, command, this.client)) return;
157
+ if (commandValidation(interaction, command, this.client)) return;
167
158
  if (command.defer?.reply !== false && this.client.handlerOptions.slash?.defer?.reply)
168
159
  await interaction.deferReply({
169
160
  ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral,
@@ -197,22 +188,21 @@ class SlashCommandEvents {
197
188
  });
198
189
  }
199
190
  }
200
- exports.SlashCommandEvents = SlashCommandEvents;
201
- class ContextCommandEvents {
191
+ export class ContextCommandEvents {
202
192
  client;
203
193
  constructor(client) {
204
194
  this.client = client;
205
195
  }
206
196
  contextCreate() {
207
197
  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) {
198
+ interaction.util = new InteractionCommandUtil(this.client, interaction);
199
+ interaction.author = await User(interaction);
200
+ if (interaction.type === InteractionType.ApplicationCommand) {
211
201
  if (this.client.commands.context.has(interaction.commandName)) {
212
202
  let command = this.client.commands.context.get(interaction.commandName);
213
203
  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;
204
+ const inhibitor = new InhibitorValidation(this.client, interaction, command);
205
+ if (commandValidation(interaction, command, this.client)) return;
216
206
  if (await inhibitor.inhibit()) return;
217
207
  if (command.conditions && (await command.conditions(interaction))) return;
218
208
  if (command.defer?.reply !== false && this.client.handlerOptions.context?.defer?.reply)
@@ -238,8 +228,7 @@ class ContextCommandEvents {
238
228
  });
239
229
  }
240
230
  }
241
- exports.ContextCommandEvents = ContextCommandEvents;
242
- class CommandsDeploy {
231
+ export class CommandsDeploy {
243
232
  client;
244
233
  constructor(client) {
245
234
  this.client = client;
@@ -263,11 +252,11 @@ class CommandsDeploy {
263
252
  if (global.slash && global.context) {
264
253
  if (guild.slash !== guild.context)
265
254
  console.info(
266
- dumfunctions_1.Style.log(
255
+ Style.log(
267
256
  `Xernerx | Warning: slash and context commands are both set to global, but don't have a matching guildId, using ${
268
257
  (await this.client.guilds.fetch(this.client.handlerOptions.slash?.guildId)).name
269
258
  }!`,
270
- { color: dumfunctions_1.Style.TextColor.Red }
259
+ { color: Style.TextColor.Red }
271
260
  )
272
261
  );
273
262
  this.put('global', guild.slash, [...contextCommands, ...slashCommands]);
@@ -284,26 +273,25 @@ class CommandsDeploy {
284
273
  }
285
274
  if (this.client.handlerOptions.context?.logging || this.client.handlerOptions.slash?.logging)
286
275
  console.info(
287
- dumfunctions_1.Style.log(
276
+ Style.log(
288
277
  `Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? 'globally' : 'locally'} and ${contextCommands.length} context commands ${
289
278
  global.context ? 'globally' : 'locally'
290
279
  }.`,
291
- { color: dumfunctions_1.Style.TextColor.Purple }
280
+ { color: Style.TextColor.Purple }
292
281
  )
293
282
  );
294
283
  } catch (error) {
295
284
  console.error(
296
- dumfunctions_1.Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
297
- color: dumfunctions_1.Style.BackgroundColor.Red,
285
+ Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
286
+ color: Style.BackgroundColor.Red,
298
287
  })
299
288
  );
300
289
  }
301
290
  });
302
291
  }
303
292
  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 });
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 });
307
296
  }
308
297
  }
309
- 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,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
+ }
@@ -3,7 +3,7 @@ declare const _default: {
3
3
  version: string;
4
4
  description: string;
5
5
  main: string;
6
- module: string;
6
+ type: string;
7
7
  keywords: string[];
8
8
  author: string;
9
9
  license: string;
@@ -19,8 +19,6 @@ declare const _default: {
19
19
  write: string;
20
20
  format: string;
21
21
  build: string;
22
- 'build:esm': string;
23
- 'build:cjs': string;
24
22
  };
25
23
  repository: {
26
24
  type: string;
@@ -30,7 +28,6 @@ declare const _default: {
30
28
  url: string;
31
29
  };
32
30
  dependencies: {
33
- '@sapphire/shapeshift': string;
34
31
  'discord.js': string;
35
32
  dumfunctions: string;
36
33
  'xernerx-extension-builder': string;
@@ -1,15 +1,13 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.default = {
1
+ export default {
4
2
  name: 'xernerx',
5
- version: '3.5.2',
3
+ version: '4.0.0',
6
4
  description: 'A bot framework for discord.js.',
7
- main: 'dist/cjs/main.js',
8
- module: 'dist/mjs/main.js',
5
+ main: 'dist/main.js',
6
+ type: 'module',
9
7
  keywords: ['discord.js', 'discord', 'framework', 'mjs', 'esm', 'cjs', 'ts'],
10
8
  author: 'Dummi',
11
9
  license: 'MIT',
12
- homepage: 'https://xernerx.github.io/xernerx/home.html',
10
+ homepage: 'https://xernerx.github.io/xernerx',
13
11
  packageManager: 'npm@8.5.5',
14
12
  scripts: {
15
13
  start: 'npm i && npm fund && npm audit fix --force && npm link && tsc -w',
@@ -20,9 +18,7 @@ exports.default = {
20
18
  commit: 'node ../.scripts/commit.js',
21
19
  write: 'npm run build && npm run format && node ../.scripts/rewritePackage.js ',
22
20
  format: 'npx prettier --write src dist',
23
- build: 'npm run build:esm && npm run build:cjs',
24
- 'build:esm': 'tsc',
25
- 'build:cjs': 'tsc --module CommonJS --outDir dist/cjs',
21
+ build: 'tsc && npm run format',
26
22
  },
27
23
  repository: {
28
24
  type: 'git',
@@ -32,14 +28,13 @@ exports.default = {
32
28
  url: 'https://github.com/xernerx/xernerx/issues',
33
29
  },
34
30
  dependencies: {
35
- '@sapphire/shapeshift': '^3.8.1',
36
- 'discord.js': '^14.7.1',
31
+ 'discord.js': '^14.9.0',
37
32
  dumfunctions: '^2.1.2',
38
- 'xernerx-extension-builder': '^0.0.8',
39
- zod: '^3.20.6',
33
+ 'xernerx-extension-builder': '^0.0.9',
34
+ zod: '^3.21.4',
40
35
  },
41
36
  devDependencies: {
42
- prettier: '^2.8.4',
43
- typescript: '^4.9.5',
37
+ prettier: '^2.8.7',
38
+ typescript: '^5.0.3',
44
39
  },
45
40
  };
@@ -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 = {})));
@@ -0,0 +1,23 @@
1
+ import { ChatInputCommandInteraction, DMChannel, Guild, GuildChannel, GuildMember, Message, MessageContextMenuCommandInteraction, User, UserContextMenuCommandInteraction } from 'discord.js';
2
+ import InteractionUtil from '../utils/InteractionUtil.js';
3
+ import MessageUtil from '../utils/MessageUtil.js';
4
+ export interface XernerxUser extends User {
5
+ owner: boolean;
6
+ voted: boolean | null;
7
+ }
8
+ export interface XernerxMember extends GuildMember {
9
+ username: string;
10
+ }
11
+ export interface XernerxGuild extends Guild {}
12
+ export interface XernerxGuildChannel extends GuildChannel {}
13
+ export interface XernerxDMChannel extends DMChannel {}
14
+ interface XernerxCommand {
15
+ util: InteractionUtil | MessageUtil;
16
+ }
17
+ export interface XernerxMessage extends Message, XernerxCommand {
18
+ user: XernerxUser;
19
+ }
20
+ export interface XernerxSlashInteraction extends ChatInputCommandInteraction, XernerxCommand {}
21
+ export interface XernerxUserContextInteraction extends UserContextMenuCommandInteraction, XernerxCommand {}
22
+ export interface XernerxMessageContextInteraction extends MessageContextMenuCommandInteraction, XernerxCommand {}
23
+ export {};
@@ -0,0 +1 @@
1
+ export {};