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.
- package/dist/build/ContextCommandBuilder.d.ts +47 -0
- package/dist/build/ContextCommandBuilder.js +78 -0
- package/dist/{cjs/build → build}/EventBuilder.d.ts +7 -6
- package/dist/build/EventBuilder.js +35 -0
- package/dist/build/InhibitorBuilder.d.ts +17 -0
- package/dist/build/InhibitorBuilder.js +26 -0
- package/dist/build/MessageCommandBuilder.d.ts +43 -0
- package/dist/build/MessageCommandBuilder.js +71 -0
- package/dist/{cjs/build → build}/SlashCommandBuilder.d.ts +16 -31
- package/dist/build/SlashCommandBuilder.js +122 -0
- package/dist/build copy/ContextCommandBuilder.d.ts +37 -0
- package/dist/build copy/ContextCommandBuilder.js +88 -0
- package/dist/{mjs/build/EventBuilder.d.ts → build copy/EventBuilder.d.ts } +4 -4
- package/dist/build copy/EventBuilder.js +34 -0
- package/dist/{cjs/build/InhibitorBuilder.d.ts → build copy/InhibitorBuilder.d.ts } +2 -2
- package/dist/build copy/InhibitorBuilder.js +27 -0
- package/dist/{cjs/build/MessageCommandBuilder.d.ts → build copy/MessageCommandBuilder.d.ts } +14 -34
- package/dist/build copy/MessageCommandBuilder.js +90 -0
- package/dist/build copy/SlashCommandBuilder.d.ts +41 -0
- package/dist/build copy/SlashCommandBuilder.js +122 -0
- package/dist/client/DBLClient.d.ts +8 -0
- package/dist/client/DBLClient.js +15 -0
- package/dist/client/Top.ggClient.d.ts +1 -0
- package/dist/client/Top.ggClient.js +1 -0
- package/dist/client/XernerxClient.d.ts +54 -0
- package/dist/client/XernerxClient.js +90 -0
- package/dist/events/messageCreate.d.ts +1 -0
- package/dist/events/messageCreate.js +1 -0
- package/dist/functions/AsyncFunctions.d.ts +1 -0
- package/dist/functions/AsyncFunctions.js +1 -0
- package/dist/functions/delay.d.ts +1 -0
- package/dist/functions/delay.js +3 -0
- package/dist/functions/deploy.d.ts +2 -0
- package/dist/functions/deploy.js +29 -0
- package/dist/functions/getPermissionBitField.d.ts +2 -0
- package/dist/functions/getPermissionBitField.js +17 -0
- package/dist/functions/hasVoted.d.ts +1 -0
- package/dist/functions/hasVoted.js +1 -0
- package/dist/functions/isOwner.d.ts +3 -0
- package/dist/functions/isOwner.js +3 -0
- package/dist/functions/isVoter.d.ts +3 -0
- package/dist/functions/isVoter.js +5 -0
- package/dist/functions/load.d.ts +3 -0
- package/dist/functions/load.js +32 -0
- package/dist/functions/reload.d.ts +2 -0
- package/dist/functions/reload.js +39 -0
- package/dist/functions/sendWebhook.d.ts +2 -0
- package/dist/functions/sendWebhook.js +12 -0
- package/dist/functions/voted.d.ts +1 -0
- package/dist/functions/voted.js +1 -0
- package/dist/functions/xernerxUser.d.ts +3 -0
- package/dist/functions/xernerxUser.js +8 -0
- package/dist/handlers/CommandHandler.d.ts +13 -0
- package/dist/handlers/CommandHandler.js +220 -0
- package/dist/handlers/EventHandler.d.ts +7 -0
- package/dist/handlers/EventHandler.js +24 -0
- package/dist/handlers/ExtensionHandler.d.ts +7 -0
- package/dist/handlers/ExtensionHandler.js +19 -0
- package/dist/handlers/Handler.d.ts +14 -0
- package/dist/handlers/Handler.js +36 -0
- package/dist/handlers/InhibitorHandler.d.ts +7 -0
- package/dist/handlers/InhibitorHandler.js +24 -0
- package/dist/handlers/WebhookHandler.d.ts +7 -0
- package/dist/handlers/WebhookHandler.js +50 -0
- package/dist/main.d.ts +11 -0
- package/dist/main.js +11 -0
- package/dist/models/Arguments.d.ts +15 -0
- package/dist/models/Arguments.js +129 -0
- package/dist/{mjs/models → models}/CommandArguments.js +2 -7
- package/dist/{mjs/models → models}/Events.js +44 -54
- package/dist/models/Extensions.js +23 -0
- package/dist/models/XernerxUser.d.ts +2 -0
- package/dist/models/XernerxUser.js +9 -0
- package/dist/tools/XernerxError.d.ts +6 -0
- package/dist/tools/XernerxError.js +10 -0
- package/dist/tools/XernerxLog.d.ts +13 -0
- package/dist/tools/XernerxLog.js +30 -0
- package/dist/tools/classes.d.ts +6 -0
- package/dist/tools/classes.js +10 -0
- package/dist/tools/loggers.d.ts +4 -0
- package/dist/tools/loggers.js +4 -0
- package/dist/{cjs/tools → tools}/package.d.ts +5 -9
- package/dist/{cjs/tools → tools}/package.js +12 -18
- package/dist/{cjs/types → types}/enums.js +8 -11
- package/dist/types/extenders.d.ts +23 -0
- package/dist/types/extenders.js +1 -0
- package/dist/types/interfaces.d.ts +224 -0
- package/dist/types/interfaces.js +1 -0
- package/dist/{cjs/types → types}/options.d.ts +13 -0
- package/dist/types/options.js +1 -0
- package/dist/types/types.d.ts +181 -0
- package/dist/types/types.js +1 -0
- package/dist/utils/ClientUtil.d.ts +6 -0
- package/dist/utils/ClientUtil.js +7 -0
- package/dist/{cjs/utils → utils}/CommandUtil.js +14 -29
- package/dist/utils/InteractionArguments.d.ts +1 -0
- package/dist/utils/InteractionArguments.js +1 -0
- package/dist/utils/InteractionUtil.d.ts +10 -0
- package/dist/utils/InteractionUtil.js +15 -0
- package/dist/utils/MessageUtil.d.ts +11 -0
- package/dist/utils/MessageUtil.js +42 -0
- package/dist/utils/Util.d.ts +5 -0
- package/dist/utils/Util.js +6 -0
- package/dist/{mjs/validators → validators}/CommandValidations.js +11 -14
- package/dist/validators/InhibitorValidations.d.ts +18 -0
- package/dist/validators/InhibitorValidations.js +34 -0
- package/dist/validators/commandValidation.d.ts +6 -0
- package/dist/validators/commandValidation.js +48 -0
- package/dist/validators/commands.d.ts +4 -0
- package/dist/validators/commands.js +25 -0
- package/package.json +10 -13
- package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -68
- package/dist/cjs/build/ContextCommandBuilder.js +0 -97
- package/dist/cjs/build/EventBuilder.js +0 -44
- package/dist/cjs/build/InhibitorBuilder.js +0 -37
- package/dist/cjs/build/MessageCommandBuilder.js +0 -100
- package/dist/cjs/build/SlashCommandBuilder.js +0 -169
- package/dist/cjs/client/XernerxClient.d.ts +0 -28
- package/dist/cjs/client/XernerxClient.js +0 -116
- package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
- package/dist/cjs/handlers/CommandHandler.js +0 -45
- package/dist/cjs/handlers/EventHandler.d.ts +0 -13
- package/dist/cjs/handlers/EventHandler.js +0 -19
- package/dist/cjs/handlers/Handler.d.ts +0 -57
- package/dist/cjs/handlers/Handler.js +0 -308
- package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
- package/dist/cjs/handlers/InhibitorHandler.js +0 -24
- package/dist/cjs/main.d.ts +0 -44
- package/dist/cjs/main.js +0 -112
- package/dist/cjs/models/CommandArguments.js +0 -106
- package/dist/cjs/models/Events.js +0 -307
- package/dist/cjs/models/Extensions.js +0 -26
- package/dist/cjs/tools/XernerxError.d.ts +0 -5
- package/dist/cjs/tools/XernerxError.js +0 -11
- package/dist/cjs/types/interfaces.d.ts +0 -25
- package/dist/cjs/types/interfaces.js +0 -2
- package/dist/cjs/types/options.js +0 -2
- package/dist/cjs/types/types.d.ts +0 -61
- package/dist/cjs/types/types.js +0 -2
- package/dist/cjs/utils/ClientUtil.d.ts +0 -25
- package/dist/cjs/utils/ClientUtil.js +0 -211
- package/dist/cjs/validators/CommandValidations.js +0 -169
- package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
- package/dist/cjs/validators/InhibitorValidations.js +0 -40
- package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -68
- package/dist/mjs/build/ContextCommandBuilder.js +0 -97
- package/dist/mjs/build/EventBuilder.js +0 -44
- package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
- package/dist/mjs/build/InhibitorBuilder.js +0 -37
- package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
- package/dist/mjs/build/MessageCommandBuilder.js +0 -100
- package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -65
- package/dist/mjs/build/SlashCommandBuilder.js +0 -169
- package/dist/mjs/client/XernerxClient.d.ts +0 -28
- package/dist/mjs/client/XernerxClient.js +0 -116
- package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
- package/dist/mjs/handlers/CommandHandler.js +0 -45
- package/dist/mjs/handlers/EventHandler.d.ts +0 -13
- package/dist/mjs/handlers/EventHandler.js +0 -19
- package/dist/mjs/handlers/Handler.d.ts +0 -57
- package/dist/mjs/handlers/Handler.js +0 -308
- package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
- package/dist/mjs/handlers/InhibitorHandler.js +0 -24
- package/dist/mjs/main.d.ts +0 -44
- package/dist/mjs/main.js +0 -112
- package/dist/mjs/models/CommandArguments.d.ts +0 -17
- package/dist/mjs/models/Events.d.ts +0 -24
- package/dist/mjs/models/Extensions.d.ts +0 -7
- package/dist/mjs/models/Extensions.js +0 -26
- package/dist/mjs/tools/XernerxError.d.ts +0 -5
- package/dist/mjs/tools/XernerxError.js +0 -11
- package/dist/mjs/tools/package.d.ts +0 -49
- package/dist/mjs/tools/package.js +0 -50
- package/dist/mjs/types/enums.d.ts +0 -44
- package/dist/mjs/types/enums.js +0 -38
- package/dist/mjs/types/interfaces.d.ts +0 -25
- package/dist/mjs/types/interfaces.js +0 -2
- package/dist/mjs/types/options.d.ts +0 -241
- package/dist/mjs/types/options.js +0 -2
- package/dist/mjs/types/types.d.ts +0 -61
- package/dist/mjs/types/types.js +0 -2
- package/dist/mjs/utils/ClientUtil.d.ts +0 -25
- package/dist/mjs/utils/ClientUtil.js +0 -211
- package/dist/mjs/utils/CommandUtil.d.ts +0 -58
- package/dist/mjs/utils/CommandUtil.js +0 -247
- package/dist/mjs/validators/CommandValidations.d.ts +0 -12
- package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
- package/dist/mjs/validators/InhibitorValidations.js +0 -40
- /package/dist/{cjs/models → models}/CommandArguments.d.ts +0 -0
- /package/dist/{cjs/models → models}/Events.d.ts +0 -0
- /package/dist/{cjs/models → models}/Extensions.d.ts +0 -0
- /package/dist/{cjs/types → types}/enums.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/CommandUtil.d.ts +0 -0
- /package/dist/{cjs/validators → validators}/CommandValidations.d.ts +0 -0
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __createBinding =
|
|
3
|
-
(this && this.__createBinding) ||
|
|
4
|
-
(Object.create
|
|
5
|
-
? function (o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () {
|
|
12
|
-
return m[k];
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}
|
|
18
|
-
: function (o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
});
|
|
22
|
-
var __setModuleDefault =
|
|
23
|
-
(this && this.__setModuleDefault) ||
|
|
24
|
-
(Object.create
|
|
25
|
-
? function (o, v) {
|
|
26
|
-
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
27
|
-
}
|
|
28
|
-
: function (o, v) {
|
|
29
|
-
o['default'] = v;
|
|
30
|
-
});
|
|
31
|
-
var __importStar =
|
|
32
|
-
(this && this.__importStar) ||
|
|
33
|
-
function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k in mod) if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
var __importDefault =
|
|
41
|
-
(this && this.__importDefault) ||
|
|
42
|
-
function (mod) {
|
|
43
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
44
|
-
};
|
|
45
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
46
|
-
exports.Handler = void 0;
|
|
47
|
-
const fs_1 = __importDefault(require('fs'));
|
|
48
|
-
const path = __importStar(require('path'));
|
|
49
|
-
const enums_js_1 = require('../types/enums.js');
|
|
50
|
-
const shapeshift_1 = require('@sapphire/shapeshift');
|
|
51
|
-
const dumfunctions_1 = require('dumfunctions');
|
|
52
|
-
// TODO - Add reload<handlerFunction>
|
|
53
|
-
// TODO - Add unload<handlerFunction>
|
|
54
|
-
// TODO - Rename load<handlerFunction>
|
|
55
|
-
// TODO - Update validator to zod
|
|
56
|
-
/**
|
|
57
|
-
* @description - The Handler class.
|
|
58
|
-
* @param {XernerxClient} client - The XernerxClient.
|
|
59
|
-
*/
|
|
60
|
-
class Handler {
|
|
61
|
-
client;
|
|
62
|
-
commands;
|
|
63
|
-
readyTimestamp;
|
|
64
|
-
constructor(client) {
|
|
65
|
-
this.client = client;
|
|
66
|
-
this.commands = [];
|
|
67
|
-
this.readyTimestamp = Number(Date.now());
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* @description - The loader for the message commands.
|
|
71
|
-
* @param {MessageCommandOptions} options - The options for the message command loader.
|
|
72
|
-
*/
|
|
73
|
-
loadAllMessageCommands(options) {
|
|
74
|
-
this.client.handlerOptions.message = shapeshift_1.s
|
|
75
|
-
.object({
|
|
76
|
-
directory: shapeshift_1.s.string,
|
|
77
|
-
prefix: shapeshift_1.s.union(shapeshift_1.s.string, shapeshift_1.s.array(shapeshift_1.s.string)),
|
|
78
|
-
allowMention: shapeshift_1.s.boolean.default(false),
|
|
79
|
-
cooldown: shapeshift_1.s.number.default(0),
|
|
80
|
-
userPermissions: shapeshift_1.s.array(shapeshift_1.s.bigint).default([]),
|
|
81
|
-
clientPermissions: shapeshift_1.s.array(shapeshift_1.s.bigint).default([]),
|
|
82
|
-
handleEdits: shapeshift_1.s.boolean.default(false),
|
|
83
|
-
handleDeletes: shapeshift_1.s.boolean.default(false),
|
|
84
|
-
handleTyping: shapeshift_1.s.boolean.default(false),
|
|
85
|
-
logging: shapeshift_1.s.boolean.default(false),
|
|
86
|
-
})
|
|
87
|
-
.parse(options);
|
|
88
|
-
const files = this.readdir(options.directory),
|
|
89
|
-
loaded = [];
|
|
90
|
-
for (const file of files) {
|
|
91
|
-
this.load(options.directory, file, enums_js_1.CommandType.MessageCommand);
|
|
92
|
-
loaded.push(file.replace('.js', ''));
|
|
93
|
-
}
|
|
94
|
-
if (this.client.handlerOptions.message?.logging)
|
|
95
|
-
console.info(
|
|
96
|
-
dumfunctions_1.Style.log(`Xernerx | Loaded ${loaded.length} message commands: ${loaded.join(', ')}.`, {
|
|
97
|
-
color: dumfunctions_1.Style.TextColor.Cyan,
|
|
98
|
-
})
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @description - The loader for the slash commands.
|
|
103
|
-
* @param {SlashCommandOptions} options - The options for the slash command loader.
|
|
104
|
-
*/
|
|
105
|
-
loadAllSlashCommands(options) {
|
|
106
|
-
this.client.handlerOptions.slash = shapeshift_1.s
|
|
107
|
-
.object({
|
|
108
|
-
directory: shapeshift_1.s.string,
|
|
109
|
-
guildId: shapeshift_1.s.string,
|
|
110
|
-
global: shapeshift_1.s.boolean,
|
|
111
|
-
cooldown: shapeshift_1.s.number.default(0),
|
|
112
|
-
userPermissions: shapeshift_1.s.array(shapeshift_1.s.bigint).default([]),
|
|
113
|
-
clientPermissions: shapeshift_1.s.array(shapeshift_1.s.bigint).default([]),
|
|
114
|
-
logging: shapeshift_1.s.boolean.default(false),
|
|
115
|
-
defer: shapeshift_1.s.object({
|
|
116
|
-
reply: shapeshift_1.s.boolean.optional,
|
|
117
|
-
ephemeral: shapeshift_1.s.boolean.optional,
|
|
118
|
-
fetchReply: shapeshift_1.s.boolean.optional,
|
|
119
|
-
}).optional,
|
|
120
|
-
})
|
|
121
|
-
.parse(options);
|
|
122
|
-
const files = this.readdir(options.directory),
|
|
123
|
-
loaded = [];
|
|
124
|
-
for (const file of files) {
|
|
125
|
-
this.load(options.directory, file, enums_js_1.CommandType.SlashCommand);
|
|
126
|
-
loaded.push(file.replace('.js', ''));
|
|
127
|
-
}
|
|
128
|
-
if (this.client.handlerOptions.slash?.logging)
|
|
129
|
-
console.info(
|
|
130
|
-
dumfunctions_1.Style.log(`Xernerx | Loaded ${loaded.length} slash commands: ${loaded.join(', ')}.`, {
|
|
131
|
-
color: dumfunctions_1.Style.TextColor.Cyan,
|
|
132
|
-
})
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* @description - The loader for the context commands.
|
|
137
|
-
* @param {ContextCommandOptions} options - The options for the context command loader.
|
|
138
|
-
*/
|
|
139
|
-
loadAllContextCommands(options) {
|
|
140
|
-
this.client.handlerOptions.context = shapeshift_1.s
|
|
141
|
-
.object({
|
|
142
|
-
directory: shapeshift_1.s.string,
|
|
143
|
-
guildId: shapeshift_1.s.string,
|
|
144
|
-
global: shapeshift_1.s.boolean,
|
|
145
|
-
cooldown: shapeshift_1.s.number.default(0),
|
|
146
|
-
userPermissions: shapeshift_1.s.array(shapeshift_1.s.bigint).default([]),
|
|
147
|
-
clientPermissions: shapeshift_1.s.array(shapeshift_1.s.bigint).default([]),
|
|
148
|
-
logging: shapeshift_1.s.boolean.default(false),
|
|
149
|
-
defer: shapeshift_1.s.object({
|
|
150
|
-
reply: shapeshift_1.s.boolean.optional,
|
|
151
|
-
ephemeral: shapeshift_1.s.boolean.optional,
|
|
152
|
-
fetchReply: shapeshift_1.s.boolean.optional,
|
|
153
|
-
}).optional,
|
|
154
|
-
})
|
|
155
|
-
.parse(options);
|
|
156
|
-
const files = this.readdir(options.directory),
|
|
157
|
-
loaded = [];
|
|
158
|
-
for (const file of files) {
|
|
159
|
-
this.load(options.directory, file, enums_js_1.CommandType.ContextCommand);
|
|
160
|
-
loaded.push(file.replace('.js', ''));
|
|
161
|
-
}
|
|
162
|
-
if (this.client.handlerOptions.context?.logging)
|
|
163
|
-
console.info(
|
|
164
|
-
dumfunctions_1.Style.log(`Xernerx | Loaded ${loaded.length} context commands: ${loaded.join(', ')}.`, {
|
|
165
|
-
color: dumfunctions_1.Style.TextColor.Cyan,
|
|
166
|
-
})
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* @description - The loader for the events.
|
|
171
|
-
* @param {EventLoadOptions} options - The options for the event loader.
|
|
172
|
-
*/
|
|
173
|
-
loadAllEvents(options) {
|
|
174
|
-
this.client.handlerOptions.events = shapeshift_1.s
|
|
175
|
-
.object({
|
|
176
|
-
directory: shapeshift_1.s.string,
|
|
177
|
-
logging: shapeshift_1.s.boolean.default(false),
|
|
178
|
-
})
|
|
179
|
-
.parse(options);
|
|
180
|
-
const files = this.readdir(options.directory),
|
|
181
|
-
loaded = [];
|
|
182
|
-
(async () => {
|
|
183
|
-
for (const file of files) {
|
|
184
|
-
try {
|
|
185
|
-
options.directory.split(/\//).shift();
|
|
186
|
-
let event = (await import('file://' + `${path.resolve(options.directory)}/${file}`)).default;
|
|
187
|
-
event = new event();
|
|
188
|
-
event.client = this.client;
|
|
189
|
-
event.commandType = enums_js_1.CommandType.Event;
|
|
190
|
-
this.client.events.set(event.name, event);
|
|
191
|
-
this.emitter(event);
|
|
192
|
-
} catch (error) {
|
|
193
|
-
console.error(dumfunctions_1.Style.log(`Xernerx | Couldn't load ${file} because <${error}>`, { color: dumfunctions_1.Style.BackgroundColor.Red }));
|
|
194
|
-
}
|
|
195
|
-
loaded.push(file.replace('.js', ''));
|
|
196
|
-
}
|
|
197
|
-
if (this.client.handlerOptions.events?.logging)
|
|
198
|
-
console.info(dumfunctions_1.Style.log(`Xernerx | Loaded ${loaded.length} events: ${loaded.join(', ')}.`, { color: dumfunctions_1.Style.TextColor.Cyan }));
|
|
199
|
-
})();
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* @description - The loader for the inhibitors.
|
|
203
|
-
* @param {InhibitorLoadOptions} options - The options for the inhibitor loader.
|
|
204
|
-
*/
|
|
205
|
-
loadAllInhibitors(options) {
|
|
206
|
-
this.client.handlerOptions.inhibitors = shapeshift_1.s
|
|
207
|
-
.object({
|
|
208
|
-
directory: shapeshift_1.s.string,
|
|
209
|
-
logging: shapeshift_1.s.boolean.default(false),
|
|
210
|
-
})
|
|
211
|
-
.parse(options);
|
|
212
|
-
const files = this.readdir(options.directory),
|
|
213
|
-
loaded = [];
|
|
214
|
-
for (const file of files) {
|
|
215
|
-
this.load(options.directory, file, enums_js_1.CommandType.Inhibitor);
|
|
216
|
-
loaded.push(file.replace('.js', ''));
|
|
217
|
-
}
|
|
218
|
-
if (this.client.handlerOptions.inhibitors?.logging)
|
|
219
|
-
console.info(
|
|
220
|
-
dumfunctions_1.Style.log(`Xernerx | Loaded ${loaded.length} inhibitors: ${loaded.join(', ')}.`, {
|
|
221
|
-
color: dumfunctions_1.Style.TextColor.Cyan,
|
|
222
|
-
})
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* @description - a reader for directories
|
|
227
|
-
* @param {string} dir - the directory to look for.
|
|
228
|
-
* @returns array of files.
|
|
229
|
-
*/
|
|
230
|
-
readdir(dir) {
|
|
231
|
-
try {
|
|
232
|
-
return fs_1.default.readdirSync(path.resolve(dir)).filter((file) => file.endsWith('.js'));
|
|
233
|
-
} catch (error) {
|
|
234
|
-
console.error(dumfunctions_1.Style.log(`Xernerx | Couldn't read ${dir} because <${error}>.`, { color: dumfunctions_1.Style.BackgroundColor.Red }));
|
|
235
|
-
}
|
|
236
|
-
return [];
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* @description file loader.
|
|
240
|
-
* @param {string} dir - the directory.
|
|
241
|
-
* @param {string} file - the file in the directory.
|
|
242
|
-
* @param {string} type - the type of file.
|
|
243
|
-
* @returns undefined
|
|
244
|
-
*/
|
|
245
|
-
async load(dir, file, type) {
|
|
246
|
-
try {
|
|
247
|
-
dir.split(/\//).shift();
|
|
248
|
-
let command = (await import('file://' + `${path.resolve(dir)}/${file}`)).default;
|
|
249
|
-
command = new command();
|
|
250
|
-
command.client = this.client;
|
|
251
|
-
command.commandType = type;
|
|
252
|
-
command.filepath = `${path.resolve(dir)}\\${file}`;
|
|
253
|
-
command.file = file;
|
|
254
|
-
if (type === enums_js_1.CommandType.MessageCommand) this.client.commands.message.set(command?.name || command?.name, command);
|
|
255
|
-
if (type === enums_js_1.CommandType.SlashCommand) {
|
|
256
|
-
this.client.commands.slash.set(command?.data?.name || command?.name, command);
|
|
257
|
-
}
|
|
258
|
-
if (type === enums_js_1.CommandType.ContextCommand) {
|
|
259
|
-
this.client.commands.context.set(command?.data?.name || command?.name, command);
|
|
260
|
-
}
|
|
261
|
-
if (type === enums_js_1.CommandType.Event) {
|
|
262
|
-
this.client.events.set(command.name, command);
|
|
263
|
-
}
|
|
264
|
-
if (type === enums_js_1.CommandType.Inhibitor) {
|
|
265
|
-
this.client.inhibitors.set(command.name, command);
|
|
266
|
-
}
|
|
267
|
-
} catch (error) {
|
|
268
|
-
console.error(dumfunctions_1.Style.log(`Xernerx | Couldn't load ${file} because <${error}>`, { color: dumfunctions_1.Style.BackgroundColor.Red }));
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* @description the event emitter to emit all events.
|
|
273
|
-
* @param {object} event - the event to be emitted.
|
|
274
|
-
* @returns void
|
|
275
|
-
*/
|
|
276
|
-
emitter(event) {
|
|
277
|
-
const client = this.client;
|
|
278
|
-
if (event.emitter === 'client') {
|
|
279
|
-
if (event.once)
|
|
280
|
-
client.once(event.name, (...args) => {
|
|
281
|
-
event.run(...args);
|
|
282
|
-
});
|
|
283
|
-
else
|
|
284
|
-
client.on(event.name, (...args) => {
|
|
285
|
-
event.run(...args);
|
|
286
|
-
});
|
|
287
|
-
} else if (event.emitter === 'rest') {
|
|
288
|
-
if (event.once)
|
|
289
|
-
client.once(event.name, (...args) => {
|
|
290
|
-
event.run(...args);
|
|
291
|
-
});
|
|
292
|
-
else
|
|
293
|
-
client.on(event.name, (...args) => {
|
|
294
|
-
event.run(...args);
|
|
295
|
-
});
|
|
296
|
-
} else if (event.emitter === 'process') {
|
|
297
|
-
if (event.once)
|
|
298
|
-
process.once(event.name, (...args) => {
|
|
299
|
-
event.run(...args);
|
|
300
|
-
});
|
|
301
|
-
else
|
|
302
|
-
process.on(event.name, (...args) => {
|
|
303
|
-
event.run(...args);
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
exports.Handler = Handler;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
2
|
-
import { InhibitorHandlerOptions } from '../types/options.js';
|
|
3
|
-
import { Handler } from './Handler.js';
|
|
4
|
-
/**
|
|
5
|
-
* @description - Inhibitor loader.
|
|
6
|
-
* @param {XernerxClient} client - The XernerxClient.
|
|
7
|
-
*/
|
|
8
|
-
export default class InhibitorHandler {
|
|
9
|
-
client: XernerxClient;
|
|
10
|
-
handler: Handler;
|
|
11
|
-
constructor(client: XernerxClient);
|
|
12
|
-
/**
|
|
13
|
-
* @description - The loader for all inhibitors.
|
|
14
|
-
* @param {InhibitorLoadOptions} options - the inhibitor loader options.
|
|
15
|
-
* @returns undefined
|
|
16
|
-
*/
|
|
17
|
-
loadAllInhibitors(options: InhibitorHandlerOptions): void;
|
|
18
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
const Handler_js_1 = require('./Handler.js');
|
|
4
|
-
/**
|
|
5
|
-
* @description - Inhibitor loader.
|
|
6
|
-
* @param {XernerxClient} client - The XernerxClient.
|
|
7
|
-
*/
|
|
8
|
-
class InhibitorHandler {
|
|
9
|
-
client;
|
|
10
|
-
handler;
|
|
11
|
-
constructor(client) {
|
|
12
|
-
this.client = client;
|
|
13
|
-
this.handler = new Handler_js_1.Handler(client);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @description - The loader for all inhibitors.
|
|
17
|
-
* @param {InhibitorLoadOptions} options - the inhibitor loader options.
|
|
18
|
-
* @returns undefined
|
|
19
|
-
*/
|
|
20
|
-
loadAllInhibitors(options) {
|
|
21
|
-
this.handler.loadAllInhibitors(options);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.default = InhibitorHandler;
|
package/dist/cjs/main.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export * from 'discord.js';
|
|
2
|
-
export * from 'dumfunctions';
|
|
3
|
-
import ExtensionBuilder from 'xernerx-extension-builder';
|
|
4
|
-
import XernerxClient from './client/XernerxClient.js';
|
|
5
|
-
import EventBuilder from './build/EventBuilder.js';
|
|
6
|
-
import InhibitorBuilder from './build/InhibitorBuilder.js';
|
|
7
|
-
import MessageCommandBuilder from './build/MessageCommandBuilder.js';
|
|
8
|
-
import ContextCommandBuilder from './build/ContextCommandBuilder.js';
|
|
9
|
-
import SlashCommandBuilder from './build/SlashCommandBuilder.js';
|
|
10
|
-
import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from './types/enums.js';
|
|
11
|
-
import XernerxError from './tools/XernerxError.js';
|
|
12
|
-
declare const xernerxVersion: string;
|
|
13
|
-
declare const _default: {
|
|
14
|
-
Client: typeof XernerxClient;
|
|
15
|
-
XernerxClient: typeof XernerxClient;
|
|
16
|
-
CommandType: typeof CommandType;
|
|
17
|
-
EventEmitterType: typeof EventEmitterType;
|
|
18
|
-
InhibitorType: typeof InhibitorType;
|
|
19
|
-
ContextCommandType: typeof ContextCommandType;
|
|
20
|
-
EventBuilder: typeof EventBuilder;
|
|
21
|
-
MessageCommandBuilder: typeof MessageCommandBuilder;
|
|
22
|
-
ContextCommandBuilder: typeof ContextCommandBuilder;
|
|
23
|
-
SlashCommandBuilder: typeof SlashCommandBuilder;
|
|
24
|
-
InhibitorBuilder: typeof InhibitorBuilder;
|
|
25
|
-
ExtensionBuilder: typeof ExtensionBuilder;
|
|
26
|
-
XernerxError: typeof XernerxError;
|
|
27
|
-
version: string;
|
|
28
|
-
};
|
|
29
|
-
export default _default;
|
|
30
|
-
export {
|
|
31
|
-
XernerxClient,
|
|
32
|
-
CommandType,
|
|
33
|
-
EventEmitterType,
|
|
34
|
-
InhibitorType,
|
|
35
|
-
ContextCommandType,
|
|
36
|
-
EventBuilder,
|
|
37
|
-
MessageCommandBuilder,
|
|
38
|
-
ContextCommandBuilder,
|
|
39
|
-
SlashCommandBuilder,
|
|
40
|
-
InhibitorBuilder,
|
|
41
|
-
ExtensionBuilder,
|
|
42
|
-
XernerxError,
|
|
43
|
-
xernerxVersion,
|
|
44
|
-
};
|
package/dist/cjs/main.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __createBinding =
|
|
3
|
-
(this && this.__createBinding) ||
|
|
4
|
-
(Object.create
|
|
5
|
-
? function (o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () {
|
|
12
|
-
return m[k];
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}
|
|
18
|
-
: function (o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
});
|
|
22
|
-
var __exportStar =
|
|
23
|
-
(this && this.__exportStar) ||
|
|
24
|
-
function (m, exports) {
|
|
25
|
-
for (var p in m) if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
-
};
|
|
27
|
-
var __importDefault =
|
|
28
|
-
(this && this.__importDefault) ||
|
|
29
|
-
function (mod) {
|
|
30
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
31
|
-
};
|
|
32
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
33
|
-
exports.xernerxVersion =
|
|
34
|
-
exports.XernerxError =
|
|
35
|
-
exports.ExtensionBuilder =
|
|
36
|
-
exports.InhibitorBuilder =
|
|
37
|
-
exports.SlashCommandBuilder =
|
|
38
|
-
exports.ContextCommandBuilder =
|
|
39
|
-
exports.MessageCommandBuilder =
|
|
40
|
-
exports.EventBuilder =
|
|
41
|
-
exports.ContextCommandType =
|
|
42
|
-
exports.InhibitorType =
|
|
43
|
-
exports.EventEmitterType =
|
|
44
|
-
exports.CommandType =
|
|
45
|
-
exports.XernerxClient =
|
|
46
|
-
void 0;
|
|
47
|
-
__exportStar(require('discord.js'), exports);
|
|
48
|
-
__exportStar(require('dumfunctions'), exports);
|
|
49
|
-
const xernerx_extension_builder_1 = __importDefault(require('xernerx-extension-builder'));
|
|
50
|
-
exports.ExtensionBuilder = xernerx_extension_builder_1.default;
|
|
51
|
-
const XernerxClient_js_1 = __importDefault(require('./client/XernerxClient.js'));
|
|
52
|
-
exports.XernerxClient = XernerxClient_js_1.default;
|
|
53
|
-
const EventBuilder_js_1 = __importDefault(require('./build/EventBuilder.js'));
|
|
54
|
-
exports.EventBuilder = EventBuilder_js_1.default;
|
|
55
|
-
const InhibitorBuilder_js_1 = __importDefault(require('./build/InhibitorBuilder.js'));
|
|
56
|
-
exports.InhibitorBuilder = InhibitorBuilder_js_1.default;
|
|
57
|
-
const MessageCommandBuilder_js_1 = __importDefault(require('./build/MessageCommandBuilder.js'));
|
|
58
|
-
exports.MessageCommandBuilder = MessageCommandBuilder_js_1.default;
|
|
59
|
-
const ContextCommandBuilder_js_1 = __importDefault(require('./build/ContextCommandBuilder.js'));
|
|
60
|
-
exports.ContextCommandBuilder = ContextCommandBuilder_js_1.default;
|
|
61
|
-
const SlashCommandBuilder_js_1 = __importDefault(require('./build/SlashCommandBuilder.js'));
|
|
62
|
-
exports.SlashCommandBuilder = SlashCommandBuilder_js_1.default;
|
|
63
|
-
const enums_js_1 = require('./types/enums.js');
|
|
64
|
-
Object.defineProperty(exports, 'CommandType', {
|
|
65
|
-
enumerable: true,
|
|
66
|
-
get: function () {
|
|
67
|
-
return enums_js_1.CommandType;
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
Object.defineProperty(exports, 'EventEmitterType', {
|
|
71
|
-
enumerable: true,
|
|
72
|
-
get: function () {
|
|
73
|
-
return enums_js_1.EventEmitterType;
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
Object.defineProperty(exports, 'ContextCommandType', {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return enums_js_1.ContextCommandType;
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
Object.defineProperty(exports, 'InhibitorType', {
|
|
83
|
-
enumerable: true,
|
|
84
|
-
get: function () {
|
|
85
|
-
return enums_js_1.InhibitorType;
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
const XernerxError_js_1 = __importDefault(require('./tools/XernerxError.js'));
|
|
89
|
-
exports.XernerxError = XernerxError_js_1.default;
|
|
90
|
-
const package_js_1 = __importDefault(require('./tools/package.js'));
|
|
91
|
-
const xernerxVersion = package_js_1.default.version;
|
|
92
|
-
exports.xernerxVersion = xernerxVersion;
|
|
93
|
-
exports.default = {
|
|
94
|
-
// Client
|
|
95
|
-
Client: XernerxClient_js_1.default,
|
|
96
|
-
XernerxClient: XernerxClient_js_1.default,
|
|
97
|
-
// Enums
|
|
98
|
-
CommandType: enums_js_1.CommandType,
|
|
99
|
-
EventEmitterType: enums_js_1.EventEmitterType,
|
|
100
|
-
InhibitorType: enums_js_1.InhibitorType,
|
|
101
|
-
ContextCommandType: enums_js_1.ContextCommandType,
|
|
102
|
-
// Builds
|
|
103
|
-
EventBuilder: EventBuilder_js_1.default,
|
|
104
|
-
MessageCommandBuilder: MessageCommandBuilder_js_1.default,
|
|
105
|
-
ContextCommandBuilder: ContextCommandBuilder_js_1.default,
|
|
106
|
-
SlashCommandBuilder: SlashCommandBuilder_js_1.default,
|
|
107
|
-
InhibitorBuilder: InhibitorBuilder_js_1.default,
|
|
108
|
-
ExtensionBuilder: xernerx_extension_builder_1.default,
|
|
109
|
-
XernerxError: XernerxError_js_1.default,
|
|
110
|
-
// Constants
|
|
111
|
-
version: xernerxVersion,
|
|
112
|
-
};
|
|
@@ -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;
|