xernerx 4.2.1 → 4.3.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 (117) hide show
  1. package/LICENSE +21 -21
  2. package/dist/build/ContextCommandBuilder.d.ts +14 -13
  3. package/dist/build/ContextCommandBuilder.js +2 -13
  4. package/dist/build/EventBuilder.d.ts +7 -7
  5. package/dist/build/EventBuilder.js +0 -6
  6. package/dist/build/InhibitorBuilder.d.ts +5 -5
  7. package/dist/build/InhibitorBuilder.js +0 -4
  8. package/dist/build/MessageCommandBuilder.d.ts +1 -0
  9. package/dist/build/MessageCommandBuilder.js +2 -16
  10. package/dist/build/SlashCommandBuilder.d.ts +13 -12
  11. package/dist/build/SlashCommandBuilder.js +2 -12
  12. package/dist/client/XernerxClient.d.ts +2 -2
  13. package/dist/client/XernerxClient.js +2 -2
  14. package/dist/handlers/ExtensionHandler.js +3 -1
  15. package/dist/handlers/WebhookHandler.js +1 -1
  16. package/dist/main.d.ts +1 -1
  17. package/dist/main.js +1 -1
  18. package/dist/types/interfaces.d.ts +3 -2
  19. package/dist/utils/ClientUtil.d.ts +1 -0
  20. package/dist/utils/ClientUtil.js +10 -0
  21. package/package.json +2 -2
  22. package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -68
  23. package/dist/cjs/build/ContextCommandBuilder.js +0 -97
  24. package/dist/cjs/build/EventBuilder.d.ts +0 -21
  25. package/dist/cjs/build/EventBuilder.js +0 -44
  26. package/dist/cjs/build/InhibitorBuilder.d.ts +0 -19
  27. package/dist/cjs/build/InhibitorBuilder.js +0 -37
  28. package/dist/cjs/build/MessageCommandBuilder.d.ts +0 -59
  29. package/dist/cjs/build/MessageCommandBuilder.js +0 -100
  30. package/dist/cjs/build/SlashCommandBuilder.d.ts +0 -64
  31. package/dist/cjs/build/SlashCommandBuilder.js +0 -168
  32. package/dist/cjs/client/XernerxClient.d.ts +0 -28
  33. package/dist/cjs/client/XernerxClient.js +0 -116
  34. package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
  35. package/dist/cjs/handlers/CommandHandler.js +0 -45
  36. package/dist/cjs/handlers/EventHandler.d.ts +0 -13
  37. package/dist/cjs/handlers/EventHandler.js +0 -19
  38. package/dist/cjs/handlers/Handler.d.ts +0 -57
  39. package/dist/cjs/handlers/Handler.js +0 -308
  40. package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
  41. package/dist/cjs/handlers/InhibitorHandler.js +0 -24
  42. package/dist/cjs/main.d.ts +0 -44
  43. package/dist/cjs/main.js +0 -112
  44. package/dist/cjs/models/CommandArguments.d.ts +0 -17
  45. package/dist/cjs/models/CommandArguments.js +0 -106
  46. package/dist/cjs/models/Events.d.ts +0 -24
  47. package/dist/cjs/models/Events.js +0 -307
  48. package/dist/cjs/models/Extensions.d.ts +0 -7
  49. package/dist/cjs/models/Extensions.js +0 -26
  50. package/dist/cjs/tools/XernerxError.d.ts +0 -5
  51. package/dist/cjs/tools/XernerxError.js +0 -11
  52. package/dist/cjs/tools/package.d.ts +0 -49
  53. package/dist/cjs/tools/package.js +0 -50
  54. package/dist/cjs/types/enums.d.ts +0 -44
  55. package/dist/cjs/types/enums.js +0 -38
  56. package/dist/cjs/types/interfaces.d.ts +0 -25
  57. package/dist/cjs/types/interfaces.js +0 -2
  58. package/dist/cjs/types/options.d.ts +0 -241
  59. package/dist/cjs/types/options.js +0 -2
  60. package/dist/cjs/types/types.d.ts +0 -61
  61. package/dist/cjs/types/types.js +0 -2
  62. package/dist/cjs/utils/ClientUtil.d.ts +0 -25
  63. package/dist/cjs/utils/ClientUtil.js +0 -211
  64. package/dist/cjs/utils/CommandUtil.d.ts +0 -58
  65. package/dist/cjs/utils/CommandUtil.js +0 -247
  66. package/dist/cjs/validators/CommandValidations.d.ts +0 -12
  67. package/dist/cjs/validators/CommandValidations.js +0 -169
  68. package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
  69. package/dist/cjs/validators/InhibitorValidations.js +0 -40
  70. package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -68
  71. package/dist/mjs/build/ContextCommandBuilder.js +0 -88
  72. package/dist/mjs/build/EventBuilder.d.ts +0 -21
  73. package/dist/mjs/build/EventBuilder.js +0 -34
  74. package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
  75. package/dist/mjs/build/InhibitorBuilder.js +0 -27
  76. package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
  77. package/dist/mjs/build/MessageCommandBuilder.js +0 -90
  78. package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -64
  79. package/dist/mjs/build/SlashCommandBuilder.js +0 -121
  80. package/dist/mjs/client/XernerxClient.d.ts +0 -28
  81. package/dist/mjs/client/XernerxClient.js +0 -108
  82. package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
  83. package/dist/mjs/handlers/CommandHandler.js +0 -42
  84. package/dist/mjs/handlers/EventHandler.d.ts +0 -13
  85. package/dist/mjs/handlers/EventHandler.js +0 -16
  86. package/dist/mjs/handlers/Handler.d.ts +0 -57
  87. package/dist/mjs/handlers/Handler.js +0 -260
  88. package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
  89. package/dist/mjs/handlers/InhibitorHandler.js +0 -21
  90. package/dist/mjs/main.d.ts +0 -44
  91. package/dist/mjs/main.js +0 -52
  92. package/dist/mjs/models/CommandArguments.d.ts +0 -17
  93. package/dist/mjs/models/CommandArguments.js +0 -101
  94. package/dist/mjs/models/Events.d.ts +0 -24
  95. package/dist/mjs/models/Events.js +0 -295
  96. package/dist/mjs/models/Extensions.d.ts +0 -7
  97. package/dist/mjs/models/Extensions.js +0 -23
  98. package/dist/mjs/tools/XernerxError.d.ts +0 -5
  99. package/dist/mjs/tools/XernerxError.js +0 -8
  100. package/dist/mjs/tools/package.d.ts +0 -49
  101. package/dist/mjs/tools/package.js +0 -48
  102. package/dist/mjs/types/enums.d.ts +0 -44
  103. package/dist/mjs/types/enums.js +0 -35
  104. package/dist/mjs/types/interfaces.d.ts +0 -25
  105. package/dist/mjs/types/interfaces.js +0 -1
  106. package/dist/mjs/types/options.d.ts +0 -241
  107. package/dist/mjs/types/options.js +0 -1
  108. package/dist/mjs/types/types.d.ts +0 -61
  109. package/dist/mjs/types/types.js +0 -1
  110. package/dist/mjs/utils/ClientUtil.d.ts +0 -25
  111. package/dist/mjs/utils/ClientUtil.js +0 -202
  112. package/dist/mjs/utils/CommandUtil.d.ts +0 -58
  113. package/dist/mjs/utils/CommandUtil.js +0 -232
  114. package/dist/mjs/validators/CommandValidations.d.ts +0 -12
  115. package/dist/mjs/validators/CommandValidations.js +0 -166
  116. package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
  117. package/dist/mjs/validators/InhibitorValidations.js +0 -36
@@ -1,17 +0,0 @@
1
- import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
2
- import { XernerxInteraction, XernerxMessage } from '../types/types.js';
3
- export declare class InteractionArguments {
4
- interaction: XernerxInteraction;
5
- constructor(interaction: XernerxInteraction);
6
- group(): string | undefined;
7
- subcommand(): string | undefined;
8
- arguments(): Record<string, object>;
9
- }
10
- interface Flag {
11
- flags: Record<string, string | boolean>;
12
- }
13
- interface Argument {
14
- [index: string]: string | number | null;
15
- }
16
- export declare function messageArguments(message: XernerxMessage, command: MessageCommandBuilder): Promise<import('discord.js').Message<boolean> | Flag | Argument | undefined>;
17
- export {};
@@ -1,106 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.messageArguments = exports.InteractionArguments = void 0;
4
- class InteractionArguments {
5
- interaction;
6
- constructor(interaction) {
7
- this.interaction = interaction;
8
- }
9
- group() {
10
- return this.interaction?.options?._group;
11
- }
12
- subcommand() {
13
- return this.interaction?.options?._subcommand;
14
- }
15
- arguments() {
16
- const options = {};
17
- if (this.interaction?.options?._hoistedOptions) {
18
- for (const option of this.interaction.options._hoistedOptions) {
19
- options[option.name] = option.channel || option.user || option.role || option.value;
20
- }
21
- }
22
- return options;
23
- }
24
- }
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;
31
- command.args
32
- .filter((c) => c.type == 'flag')
33
- .map((flag) => {
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
- }
40
- }
41
- if (!args.flags[flag.name]) args.flags[flag.name] = false;
42
- });
43
- for (const argument of command.args) {
44
- args = args;
45
- let content = message.content
46
- .split(/ +/)
47
- .slice(1)
48
- .join(separator)
49
- .replace(new RegExp(`${separator}${separator}+`, 'g'), separator)
50
- .split(separator)
51
- .slice(i);
52
- if (content.join(separator) != '' && argument.type !== 'flag') {
53
- if (argument?.content?.includes(content[0])) {
54
- args[argument.name] = content[0];
55
- } else if (argument.type == 'string') {
56
- args[argument.name] = content[0];
57
- } else if (argument.type == 'number') {
58
- args[argument.name] = parseInt(content[0]);
59
- } else if (argument.type == 'boolean') {
60
- if (content[0]?.toLowerCase() != 'true' && content[0]?.toLowerCase() != 'false') content[0] = null;
61
- args[argument.name] = content[0];
62
- } else if (argument.type == 'user') {
63
- let user = message.client.users.cache.find((u) => u?.username?.toLowerCase()?.includes(content[0])) || null;
64
- try {
65
- user = (await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g, ''))) || null;
66
- } catch (e) {
67
- user = null;
68
- }
69
- args[argument.name] = user;
70
- } else if (argument.type == 'role') {
71
- let role = message.guild?.roles.cache.find((r) => r?.name?.toLowerCase()?.includes(content[0])) || null;
72
- try {
73
- role = (await message.guild?.roles.fetch(role?.id || content[0].replace(/<@&?|>/g, ''))) || null;
74
- } catch (e) {
75
- role = null;
76
- }
77
- args[argument.name] = role;
78
- } else if (argument.type == 'member') {
79
- let member = message.guild?.members.cache.find((m) => m?.nickname?.toLowerCase()?.includes(content[0]) || m?.user?.username?.toLowerCase()?.includes(content[0])) || null;
80
- try {
81
- member = (await message.guild?.members.fetch(member?.id || content[0].replace(/<@!?|>/g, ''))) || null;
82
- } catch (e) {
83
- member = null;
84
- }
85
- args[argument.name] = member;
86
- } else if (argument.type == 'channel') {
87
- let channel = message.guild?.channels.cache.find((c) => c?.name?.toLowerCase()?.includes(content[0]));
88
- try {
89
- channel = await message.client.channels.fetch(channel?.id || content[0].replace(/<#|>/g, ''));
90
- } catch (e) {
91
- channel = null;
92
- }
93
- args[argument.name] = channel;
94
- } else if (argument.type == 'rest') {
95
- args[argument.name] = content.join(separator);
96
- break;
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;
101
- i++;
102
- } else args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
103
- }
104
- return args;
105
- }
106
- exports.messageArguments = messageArguments;
@@ -1,24 +0,0 @@
1
- import XernerxClient from '../client/XernerxClient.js';
2
- export declare class MessageCommandEvents {
3
- client: XernerxClient;
4
- constructor(client: XernerxClient);
5
- messageCreate(): void;
6
- messageUpdate(): void;
7
- messageDelete(): void;
8
- }
9
- export declare class SlashCommandEvents {
10
- client: XernerxClient;
11
- constructor(client: XernerxClient);
12
- slashCreate(): void;
13
- }
14
- export declare class ContextCommandEvents {
15
- client: XernerxClient;
16
- constructor(client: XernerxClient);
17
- contextCreate(): void;
18
- }
19
- export declare class CommandsDeploy {
20
- private client;
21
- constructor(client: XernerxClient);
22
- deploy(): void;
23
- private put;
24
- }
@@ -1,307 +0,0 @@
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 {
16
- client;
17
- constructor(client) {
18
- this.client = client;
19
- }
20
- messageCreate() {
21
- this.client.on('messageCreate', async (message) => {
22
- if (!message.author.bot) {
23
- let command = undefined,
24
- px = undefined;
25
- message.author.isOwner = this.client.util.isOwner(message.author.id);
26
- message.util = new CommandUtil_js_1.MessageCommandUtil(this.client, message);
27
- const commands = this.client.commands.message;
28
- commands
29
- .filter((c) => !c.regex)
30
- .map(async (cmd) => {
31
- if (cmd.prefix) {
32
- cmd.prefix.map((prefix) => {
33
- if (message.content.startsWith(prefix)) {
34
- command = message.content.replace(prefix, '').split(/ +/).shift();
35
- px = prefix;
36
- }
37
- });
38
- }
39
- if (this.client.handlerOptions.message?.prefix) {
40
- const prefix = Array.isArray(this.client.handlerOptions.message.prefix) ? this.client.handlerOptions.message.prefix : [this.client.handlerOptions.message.prefix];
41
- prefix.map((prefix) => {
42
- if (message.content.startsWith(prefix)) {
43
- command = message.content.replace(prefix, '').split(/ +/).shift();
44
- px = prefix;
45
- }
46
- });
47
- }
48
- if (this.client.handlerOptions.message?.allowMention) {
49
- if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
50
- command = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
51
- px = 'MentionPrefix';
52
- }
53
- }
54
- const prefix = Array.isArray(this.client.handlerOptions.message?.prefix) ? this.client.handlerOptions.message?.prefix : [this.client.handlerOptions.message?.prefix];
55
- if (
56
- (cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
57
- (cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')
58
- ) {
59
- try {
60
- 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;
63
- 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));
66
- this.client.emit('commandRun', message, cmd);
67
- } catch (error) {
68
- return this.client.emit('commandError', message, error, cmd);
69
- }
70
- }
71
- });
72
- }
73
- });
74
- }
75
- messageUpdate() {
76
- this.client.on('messageUpdate', async (old, message) => {
77
- message = message;
78
- if (!message.author?.bot) {
79
- let command = undefined,
80
- 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);
83
- const commands = this.client.commands.message;
84
- commands
85
- .filter((c) => !c.regex)
86
- .map(async (cmd) => {
87
- if (cmd.prefix) {
88
- cmd.prefix.map((prefix) => {
89
- if (message?.content?.startsWith(prefix)) {
90
- command = message.content.replace(prefix, '').split(/ +/).shift();
91
- px = prefix;
92
- }
93
- });
94
- }
95
- if (this.client.handlerOptions.message?.prefix) {
96
- const prefix = Array.isArray(this.client.handlerOptions.message.prefix) ? this.client.handlerOptions.message.prefix : [this.client.handlerOptions.message.prefix];
97
- prefix.map((prefix) => {
98
- if (message?.content?.startsWith(prefix)) {
99
- command = message.content.replace(prefix, '').split(/ +/).shift();
100
- px = prefix;
101
- }
102
- });
103
- }
104
- if (this.client.handlerOptions.message?.allowMention) {
105
- if (message.mentions.users.has(this.client.user?.id || '') || message.mentions.repliedUser?.id === this.client.user?.id) {
106
- command = message?.content?.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
107
- px = 'MentionPrefix';
108
- }
109
- }
110
- const prefix = Array.isArray(this.client.handlerOptions.message?.prefix) ? this.client.handlerOptions.message?.prefix : [this.client.handlerOptions.message?.prefix];
111
- if (
112
- (cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
113
- (cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')
114
- ) {
115
- try {
116
- if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
117
- 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;
120
- 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));
123
- this.client.emit('commandRun', message, cmd);
124
- } catch (error) {
125
- return this.client.emit('commandError', message, error, cmd);
126
- }
127
- }
128
- });
129
- }
130
- });
131
- }
132
- messageDelete() {
133
- this.client.on('messageDelete', async (message) => {
134
- if (this.client.cache.messages.has(message.id) && this.client.handlerOptions.message?.handleDeletes) {
135
- try {
136
- if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
137
- const msg = this.client.cache.messages.get(message.id);
138
- const response = await message.channel.messages.fetch(msg?.response);
139
- await response.delete();
140
- } catch (error) {
141
- this.client.emit('commandError', message, error, null);
142
- }
143
- }
144
- });
145
- }
146
- }
147
- exports.MessageCommandEvents = MessageCommandEvents;
148
- class SlashCommandEvents {
149
- client;
150
- constructor(client) {
151
- this.client = client;
152
- }
153
- slashCreate() {
154
- 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) {
158
- if (this.client.commands.slash.has(interaction.commandName)) {
159
- let command = this.client.commands.slash.get(interaction.commandName);
160
- const argumentsInfo = new CommandArguments_js_1.InteractionArguments(interaction);
161
- try {
162
- const inhibitor = new InhibitorValidations_js_1.InhibitorValidation(this.client, interaction, command);
163
- if (await inhibitor.inhibit()) return;
164
- if ((0, CommandValidations_js_1.default)(interaction, command, this.client)) return;
165
- if (command.defer?.reply !== false && this.client.handlerOptions.slash?.defer?.reply)
166
- await interaction.deferReply({
167
- ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral,
168
- fetchReply: this.client.handlerOptions.slash?.defer?.fetchReply,
169
- });
170
- if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
171
- await interaction.deferReply({
172
- ephemeral: command.defer?.ephemeral,
173
- fetchReply: command.defer?.fetchReply,
174
- });
175
- if (
176
- command.conditions &&
177
- (await command.conditions(interaction, {
178
- group: argumentsInfo.group(),
179
- subcommand: argumentsInfo.subcommand(),
180
- args: await argumentsInfo.arguments(),
181
- }))
182
- )
183
- return;
184
- await command.exec(interaction, {
185
- group: argumentsInfo.group(),
186
- subcommand: argumentsInfo.subcommand(),
187
- args: await argumentsInfo.arguments(),
188
- });
189
- this.client.emit('commandRun', interaction, command);
190
- } catch (error) {
191
- this.client.emit('commandError', interaction, error, command);
192
- }
193
- }
194
- }
195
- });
196
- }
197
- }
198
- exports.SlashCommandEvents = SlashCommandEvents;
199
- class ContextCommandEvents {
200
- client;
201
- constructor(client) {
202
- this.client = client;
203
- }
204
- contextCreate() {
205
- 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) {
209
- if (this.client.commands.context.has(interaction.commandName)) {
210
- let command = this.client.commands.context.get(interaction.commandName);
211
- 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;
214
- if (await inhibitor.inhibit()) return;
215
- if (command.conditions && (await command.conditions(interaction))) return;
216
- if (command.defer?.reply !== false && this.client.handlerOptions.context?.defer?.reply)
217
- await interaction.deferReply({
218
- ephemeral: this.client.handlerOptions.context?.defer?.ephemeral,
219
- fetchReply: this.client.handlerOptions.context?.defer?.fetchReply,
220
- });
221
- if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
222
- await interaction.deferReply({
223
- ephemeral: command.defer?.ephemeral,
224
- fetchReply: command.defer?.fetchReply,
225
- });
226
- let args = {};
227
- if (command.type === 3) args = await interaction.channel.messages.fetch(interaction.targetId);
228
- if (command.type === 2) args = await this.client.users.fetch(interaction.targetId);
229
- await command.exec(interaction, args);
230
- this.client.emit('commandRun', interaction, command);
231
- } catch (error) {
232
- this.client.emit('commandError', interaction, error, command);
233
- }
234
- }
235
- }
236
- });
237
- }
238
- }
239
- exports.ContextCommandEvents = ContextCommandEvents;
240
- class CommandsDeploy {
241
- client;
242
- constructor(client) {
243
- this.client = client;
244
- }
245
- deploy() {
246
- this.client.once('ready', async (client) => {
247
- const slashCommands = [],
248
- contextCommands = [];
249
- this.client.commands.context.map((command) => (command.data ? contextCommands.push(command.data.toJSON()) : null));
250
- this.client.commands.slash.map((command) => (command.data ? slashCommands.push(command.data.toJSON()) : null));
251
- try {
252
- const global = {
253
- slash: this.client.handlerOptions.slash?.global,
254
- context: this.client.handlerOptions.context?.global,
255
- };
256
- const guild = {
257
- slash: this.client.handlerOptions.slash?.guildId,
258
- context: this.client.handlerOptions.context?.guildId,
259
- };
260
- if (!guild.slash && !guild.context) return;
261
- if (global.slash && global.context) {
262
- if (guild.slash !== guild.context)
263
- console.info(
264
- dumfunctions_1.Style.log(
265
- `Xernerx | Warning: slash and context commands are both set to global, but don't have a matching guildId, using ${
266
- (await this.client.guilds.fetch(this.client.handlerOptions.slash?.guildId)).name
267
- }!`,
268
- { color: dumfunctions_1.Style.TextColor.Red }
269
- )
270
- );
271
- this.put('global', guild.slash, [...contextCommands, ...slashCommands]);
272
- this.put('guild', guild.slash, []);
273
- }
274
- if (global.slash && global.context === false) {
275
- this.put('global', guild.slash, slashCommands);
276
- }
277
- if (global.slash === false && global.context) {
278
- this.put('global', guild.context, contextCommands);
279
- }
280
- if (global.slash === false && global.context === false) {
281
- this.put('guild', guild.slash, [...contextCommands, ...slashCommands]);
282
- }
283
- if (this.client.handlerOptions.context?.logging || this.client.handlerOptions.slash?.logging)
284
- console.info(
285
- dumfunctions_1.Style.log(
286
- `Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? 'globally' : 'locally'} and ${contextCommands.length} context commands ${
287
- global.context ? 'globally' : 'locally'
288
- }.`,
289
- { color: dumfunctions_1.Style.TextColor.Purple }
290
- )
291
- );
292
- } catch (error) {
293
- console.error(
294
- dumfunctions_1.Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
295
- color: dumfunctions_1.Style.BackgroundColor.Red,
296
- })
297
- );
298
- }
299
- });
300
- }
301
- 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 });
305
- }
306
- }
307
- exports.CommandsDeploy = CommandsDeploy;
@@ -1,7 +0,0 @@
1
- import XernerxExtensionBuilder from 'xernerx-extension-builder';
2
- import XernerxClient from '../client/XernerxClient.js';
3
- export default class Extensions {
4
- client: XernerxClient;
5
- constructor(client: XernerxClient);
6
- load(extensions: Array<XernerxExtensionBuilder>, logging?: boolean): Promise<void>;
7
- }
@@ -1,26 +0,0 @@
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;
@@ -1,5 +0,0 @@
1
- export default class XernerxError {
2
- name: string;
3
- message: string;
4
- constructor(message?: string);
5
- }
@@ -1,11 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- class XernerxError {
4
- name;
5
- message;
6
- constructor(message) {
7
- this.name = 'XernerxError';
8
- this.message = message || '';
9
- }
10
- }
11
- exports.default = XernerxError;
@@ -1,49 +0,0 @@
1
- declare const _default: {
2
- name: string;
3
- version: string;
4
- type: string;
5
- description: string;
6
- main: string;
7
- keywords: string[];
8
- author: string;
9
- license: string;
10
- homepage: string;
11
- packageManager: string;
12
- exports: {
13
- import: string;
14
- require: string;
15
- types: string;
16
- node: null;
17
- default: null;
18
- };
19
- scripts: {
20
- start: string;
21
- patch: string;
22
- minor: string;
23
- major: string;
24
- site: string;
25
- commit: string;
26
- write: string;
27
- build: string;
28
- };
29
- repository: {
30
- type: string;
31
- url: string;
32
- };
33
- bugs: {
34
- url: string;
35
- };
36
- dependencies: {
37
- '@sapphire/shapeshift': string;
38
- 'discord.js': string;
39
- dumfunctions: string;
40
- 'xernerx-extension-builder': string;
41
- zod: string;
42
- };
43
- devDependencies: {
44
- prettier: string;
45
- tsup: string;
46
- typescript: string;
47
- };
48
- };
49
- export default _default;
@@ -1,50 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.default = {
4
- name: 'xernerx',
5
- version: '3.5.1',
6
- type: 'module',
7
- description: 'A bot framework for discord.js.',
8
- main: 'dist/main.js',
9
- keywords: ['discord.js', 'discord', 'framework', 'mjs', 'esm', 'cjs', 'ts'],
10
- author: 'Dummi',
11
- license: 'MIT',
12
- homepage: 'https://xernerx.github.io/xernerx/home.html',
13
- 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
- scripts: {
22
- start: 'npm i && npm fund && npm audit fix --force && npm link && tsc -w',
23
- patch: 'npm run write && git add . && npm run commit && npm version patch && npm publish && git push',
24
- minor: 'npm run write && git add . && npm run commit && npm version minor && npm publish && git push',
25
- major: 'npm run write && git add . && npm run commit && npm version major && npm publish && git push',
26
- site: 'git add docs && npm run commit && git push',
27
- 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',
30
- },
31
- repository: {
32
- type: 'git',
33
- url: 'git+https://github.com/xernerx/xernerx.git',
34
- },
35
- bugs: {
36
- url: 'https://github.com/xernerx/xernerx/issues',
37
- },
38
- dependencies: {
39
- '@sapphire/shapeshift': '^3.8.1',
40
- 'discord.js': '^14.7.1',
41
- dumfunctions: '^2.1.1',
42
- 'xernerx-extension-builder': '^0.0.5',
43
- zod: '^3.20.6',
44
- },
45
- devDependencies: {
46
- prettier: '^2.8.4',
47
- tsup: '^6.6.0',
48
- typescript: '^4.9.5',
49
- },
50
- };
@@ -1,44 +0,0 @@
1
- import {
2
- SlashCommandStringOption,
3
- SlashCommandNumberOption,
4
- SlashCommandIntegerOption,
5
- SlashCommandBooleanOption,
6
- SlashCommandUserOption,
7
- SlashCommandChannelOption,
8
- SlashCommandRoleOption,
9
- SlashCommandMentionableOption,
10
- } from 'discord.js';
11
- export declare enum InhibitorType {
12
- Member = 'Member',
13
- User = 'User',
14
- Guild = 'Guild',
15
- SlashCommand = 'SlashCommand',
16
- MessageCommand = 'MessageCommand',
17
- ContextCommand = 'ContextCommand',
18
- Command = 'Command',
19
- Message = 'Message',
20
- Interaction = 'Interaction',
21
- Channel = 'Channel',
22
- }
23
- export declare enum CommandType {
24
- Message = 'MessageCommand',
25
- Slash = 'SlashCommand',
26
- Context = 'ContextCommand',
27
- Event = 'Event',
28
- Inhibitor = 'Inhibitor',
29
- MessageCommand = 'MessageCommand',
30
- SlashCommand = 'SlashCommand',
31
- ContextCommand = 'ContextCommand',
32
- }
33
- export declare enum ContextCommandType {
34
- Message = 3,
35
- User = 2,
36
- }
37
- export declare enum EventEmitterType {
38
- Client = 'client',
39
- Rest = 'rest',
40
- Process = 'process',
41
- }
42
- export type SlashCommandOptionChoices = SlashCommandStringOption | SlashCommandNumberOption | SlashCommandIntegerOption;
43
- export type SlashCommandOption = SlashCommandOptionChoices | SlashCommandBooleanOption | SlashCommandUserOption | SlashCommandChannelOption | SlashCommandRoleOption | SlashCommandMentionableOption;
44
- export type SlashArgumentTypes = 'String' | 'Number' | 'Boolean' | 'User' | 'Channel' | 'Role' | 'Mentionable' | 'Integer';