xernerx 4.4.5 → 4.4.7
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 +22 -30
- package/dist/build/ContextCommandBuilder.js +38 -38
- package/dist/build/EventBuilder.d.ts +1 -1
- package/dist/build/EventBuilder.js +1 -1
- package/dist/build/InhibitorBuilder.js +1 -1
- package/dist/build/MessageCommandBuilder.d.ts +19 -25
- package/dist/build/MessageCommandBuilder.js +33 -33
- package/dist/build/SlashCommandBuilder.d.ts +22 -30
- package/dist/build/SlashCommandBuilder.js +47 -47
- package/dist/client/XernerxClient.d.ts +21 -29
- package/dist/client/XernerxClient.js +32 -32
- package/dist/client/XernerxShardClient.js +3 -5
- package/dist/functions/deploy.js +15 -12
- package/dist/functions/load.js +2 -1
- package/dist/functions/reload.js +11 -8
- package/dist/functions/sendWebhook.js +2 -1
- package/dist/functions/setPresence.d.ts +1 -1
- package/dist/functions/setPresence.js +10 -11
- package/dist/handlers/CommandHandler.js +104 -81
- package/dist/handlers/EventHandler.js +2 -2
- package/dist/handlers/ExtensionHandler.js +4 -2
- package/dist/handlers/Handler.js +15 -5
- package/dist/handlers/InhibitorHandler.js +2 -2
- package/dist/handlers/WebhookHandler.d.ts +3 -1
- package/dist/handlers/WebhookHandler.js +5 -8
- package/dist/main.d.ts +21 -28
- package/dist/main.js +21 -28
- package/dist/models/Arguments.js +62 -47
- package/dist/tools/XernerxLog.js +1 -6
- package/dist/types/extenders.d.ts +8 -4
- package/dist/types/interfaces.d.ts +6 -12
- package/dist/types/types.d.ts +6 -174
- package/dist/utils/ClientUtil.d.ts +3 -3
- package/dist/utils/ClientUtil.js +13 -7
- package/dist/utils/InteractionUtil.d.ts +1 -1
- package/dist/utils/MessageUtil.d.ts +1 -1
- package/dist/utils/MessageUtil.js +8 -4
- package/dist/validators/commandValidation.js +28 -18
- package/dist/validators/inhibitorValidations.d.ts +1 -14
- package/package.json +1 -1
package/dist/functions/deploy.js
CHANGED
|
@@ -5,29 +5,32 @@ const commands = { slash: [], context: [] };
|
|
|
5
5
|
export default function deploy(client, type) {
|
|
6
6
|
client.prependOnceListener('ready', (client) => {
|
|
7
7
|
commands[type] = client.commands[type].map((command) => command.data.toJSON());
|
|
8
|
-
if (!(!!client.modules.options.slash && !!client.modules.options.context && commands.slash.length > 0 && commands.context.length > 0))
|
|
8
|
+
if (!(!!client.modules.options.slash && !!client.modules.options.context && commands.slash.length > 0 && commands.context.length > 0))
|
|
9
|
+
return;
|
|
9
10
|
try {
|
|
10
11
|
if (client.settings.global) {
|
|
11
12
|
put(client, client.settings.global, [...commands.slash, ...commands.context]);
|
|
12
13
|
put(client, !client.settings.global, []);
|
|
13
|
-
}
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
14
16
|
put(client, !client.settings.global, [...commands.slash, ...commands.context]);
|
|
15
17
|
put(client, client.settings.global, []);
|
|
16
18
|
}
|
|
17
|
-
}
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
18
21
|
new XernerxLog(client).error(`An error occurred while deploying the interaction commands!`, error);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
client.settings.global ? 'globally' : 'locally'
|
|
23
|
-
}.`
|
|
24
|
-
);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
new XernerxLog(client).info(`Deployed ${[client.commands.message.size, client.commands.slash.size, client.commands.context.size].reduce((a, b) => (a += b))} Commands ${client.settings.global ? 'globally' : 'locally'}.`);
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
function put(client, global, body) {
|
|
29
29
|
const rest = new REST({ version: GatewayVersion }).setToken(client.token);
|
|
30
|
-
if (!global && !client.settings?.local)
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
if (!global && !client.settings?.local)
|
|
31
|
+
throw new XernerxError(`No guild ID provided as local guild!`);
|
|
32
|
+
if (!global && client.settings?.local)
|
|
33
|
+
rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
|
|
34
|
+
else
|
|
35
|
+
rest.put(Routes.applicationCommands(client.user?.id), { body });
|
|
33
36
|
}
|
package/dist/functions/load.js
CHANGED
|
@@ -7,7 +7,8 @@ export default async function load(client, path, type) {
|
|
|
7
7
|
file.client = client;
|
|
8
8
|
fileSave(client, file, type);
|
|
9
9
|
return file;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
11
12
|
new XernerxLog(client).error(`Couldn't load ${type} ${path.match(/\w*\.js$/gim)?.at(0) || path}`, error);
|
|
12
13
|
}
|
|
13
14
|
}
|
package/dist/functions/reload.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var FileTypes;
|
|
2
2
|
(function (FileTypes) {
|
|
3
|
-
FileTypes[
|
|
4
|
-
FileTypes[
|
|
5
|
-
FileTypes[
|
|
6
|
-
FileTypes[
|
|
7
|
-
FileTypes[
|
|
3
|
+
FileTypes["message"] = "MessageCommand";
|
|
4
|
+
FileTypes["slash"] = "SlashCommand";
|
|
5
|
+
FileTypes["context"] = "ContextCommand";
|
|
6
|
+
FileTypes["event"] = "Event";
|
|
7
|
+
FileTypes["inhibitor"] = "Inhibitor";
|
|
8
8
|
})(FileTypes || (FileTypes = {}));
|
|
9
9
|
export default function reload(client, type) {
|
|
10
10
|
const files = [];
|
|
@@ -31,9 +31,12 @@ export default function reload(client, type) {
|
|
|
31
31
|
filedata.fileType = FileTypes[type];
|
|
32
32
|
filedata.filePath = file;
|
|
33
33
|
filedata.client = client;
|
|
34
|
-
if (type === 'message' || type === 'slash' || type === 'context')
|
|
35
|
-
|
|
36
|
-
if (type === '
|
|
34
|
+
if (type === 'message' || type === 'slash' || type === 'context')
|
|
35
|
+
client.commands[type].set(filedata.name, filedata);
|
|
36
|
+
if (type === 'event')
|
|
37
|
+
client.events.set(filedata.name, filedata);
|
|
38
|
+
if (type === 'inhibitor')
|
|
39
|
+
client.inhibitors.set(filedata.name, filedata);
|
|
37
40
|
return filedata;
|
|
38
41
|
});
|
|
39
42
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import XernerxClient from '../main.js';
|
|
2
2
|
import { PresenceOptions } from '../types/interfaces.js';
|
|
3
|
-
export default function setPresence(client: XernerxClient, options: PresenceOptions): import(
|
|
3
|
+
export default function setPresence(client: XernerxClient, options: PresenceOptions): import("discord.js").ClientPresence | undefined;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
export default function setPresence(client, options) {
|
|
2
|
-
const presence = () =>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
2
|
+
const presence = () => client.user?.setPresence({
|
|
3
|
+
activities: [
|
|
4
|
+
{
|
|
5
|
+
name: options.text,
|
|
6
|
+
type: options.type,
|
|
7
|
+
url: options.url,
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
status: options.status,
|
|
11
|
+
});
|
|
13
12
|
let response = presence();
|
|
14
13
|
if (options.interval)
|
|
15
14
|
setInterval(() => {
|
|
@@ -15,26 +15,28 @@ export default class CommandHandler extends Handler {
|
|
|
15
15
|
super(client);
|
|
16
16
|
}
|
|
17
17
|
loadMessageCommands(options) {
|
|
18
|
-
if (!this.client.options.intents.has(GatewayIntentBits.MessageContent))
|
|
19
|
-
|
|
18
|
+
if (!this.client.options.intents.has(GatewayIntentBits.MessageContent))
|
|
19
|
+
new XernerxLog(this.client).warn(`Message commands might not work as you're missing the intent MessageContent!`);
|
|
20
|
+
if (!this.client.options.intents.has(GatewayIntentBits.GuildMessages))
|
|
21
|
+
new XernerxLog(this.client).warn(`Message commands might not work as you're missing the intent GuildMessages!`);
|
|
20
22
|
options = z
|
|
21
23
|
.object({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
32
|
-
.default({}),
|
|
33
|
-
handleEdits: z.boolean().default(false),
|
|
34
|
-
handleDeletes: z.boolean().default(false),
|
|
35
|
-
handleTyping: z.boolean().default(false),
|
|
36
|
-
logging: z.boolean().default(false),
|
|
24
|
+
directory: z.string(),
|
|
25
|
+
prefix: z.string().or(z.array(z.string())),
|
|
26
|
+
allowMention: z.boolean().default(false),
|
|
27
|
+
cooldown: z.number().default(0),
|
|
28
|
+
permissions: z
|
|
29
|
+
.object({
|
|
30
|
+
user: z.array(z.string()).default([]),
|
|
31
|
+
client: z.array(z.string()).default([]),
|
|
32
|
+
dm: z.boolean().default(true),
|
|
37
33
|
})
|
|
34
|
+
.default({}),
|
|
35
|
+
handleEdits: z.boolean().default(false),
|
|
36
|
+
handleDeletes: z.boolean().default(false),
|
|
37
|
+
handleTyping: z.boolean().default(false),
|
|
38
|
+
logging: z.boolean().default(false),
|
|
39
|
+
})
|
|
38
40
|
.parse(options);
|
|
39
41
|
this.client.modules.options.message = options;
|
|
40
42
|
const files = this.readdir(options.directory);
|
|
@@ -63,27 +65,28 @@ export default class CommandHandler extends Handler {
|
|
|
63
65
|
// return reload(this.client, 'message');
|
|
64
66
|
// }
|
|
65
67
|
loadSlashCommands(options) {
|
|
66
|
-
if (!this.client.settings.local)
|
|
68
|
+
if (!this.client.settings.local)
|
|
69
|
+
new XernerxLog(this.client).warn(`Slash commands might not work as you haven't specified a local guild ID.`);
|
|
67
70
|
options = z
|
|
68
71
|
.object({
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
})
|
|
85
|
-
.default({}),
|
|
72
|
+
directory: z.string(),
|
|
73
|
+
cooldown: z.number().default(0),
|
|
74
|
+
permissions: z
|
|
75
|
+
.object({
|
|
76
|
+
user: z.array(z.string()).default([]),
|
|
77
|
+
client: z.array(z.string()).default([]),
|
|
78
|
+
dm: z.boolean().default(true),
|
|
79
|
+
})
|
|
80
|
+
.default({}),
|
|
81
|
+
logging: z.boolean().default(false),
|
|
82
|
+
defer: z
|
|
83
|
+
.object({
|
|
84
|
+
reply: z.boolean().default(false),
|
|
85
|
+
ephemeral: z.boolean().default(false),
|
|
86
|
+
fetchReply: z.boolean().default(false),
|
|
86
87
|
})
|
|
88
|
+
.default({}),
|
|
89
|
+
})
|
|
87
90
|
.parse(options);
|
|
88
91
|
this.client.modules.options.slash = options;
|
|
89
92
|
const files = this.readdir(options.directory);
|
|
@@ -100,27 +103,28 @@ export default class CommandHandler extends Handler {
|
|
|
100
103
|
});
|
|
101
104
|
}
|
|
102
105
|
loadContextCommands(options) {
|
|
103
|
-
if (!this.client.settings.local)
|
|
106
|
+
if (!this.client.settings.local)
|
|
107
|
+
new XernerxLog(this.client).warn(`Context commands might not work as you haven't specified a local guild ID.`);
|
|
104
108
|
options = z
|
|
105
109
|
.object({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
})
|
|
114
|
-
.default({}),
|
|
115
|
-
logging: z.boolean().default(false),
|
|
116
|
-
defer: z
|
|
117
|
-
.object({
|
|
118
|
-
reply: z.boolean().default(false),
|
|
119
|
-
ephemeral: z.boolean().default(false),
|
|
120
|
-
fetchReply: z.boolean().default(false),
|
|
121
|
-
})
|
|
122
|
-
.default({}),
|
|
110
|
+
directory: z.string(),
|
|
111
|
+
cooldown: z.number().default(0),
|
|
112
|
+
permissions: z
|
|
113
|
+
.object({
|
|
114
|
+
user: z.array(z.string()).default([]),
|
|
115
|
+
client: z.array(z.string()).default([]),
|
|
116
|
+
dm: z.boolean().default(true),
|
|
123
117
|
})
|
|
118
|
+
.default({}),
|
|
119
|
+
logging: z.boolean().default(false),
|
|
120
|
+
defer: z
|
|
121
|
+
.object({
|
|
122
|
+
reply: z.boolean().default(false),
|
|
123
|
+
ephemeral: z.boolean().default(false),
|
|
124
|
+
fetchReply: z.boolean().default(false),
|
|
125
|
+
})
|
|
126
|
+
.default({}),
|
|
127
|
+
})
|
|
124
128
|
.parse(options);
|
|
125
129
|
this.client.modules.options.context = options;
|
|
126
130
|
const files = this.readdir(options.directory);
|
|
@@ -138,14 +142,18 @@ export default class CommandHandler extends Handler {
|
|
|
138
142
|
}
|
|
139
143
|
async messageCommandRun(message, message2) {
|
|
140
144
|
const filetype = 'MessageCommand';
|
|
141
|
-
if (message.author.bot)
|
|
145
|
+
if (message.author.bot)
|
|
146
|
+
return;
|
|
142
147
|
message.util = new MessageUtil(this.client, message);
|
|
143
148
|
message.user = await xernerxUser(message, this.client);
|
|
144
|
-
if (typeof message2 === 'object')
|
|
149
|
+
if (typeof message2 === 'object')
|
|
150
|
+
message = message2;
|
|
145
151
|
if (message2 === 'delete') {
|
|
146
|
-
if (!this.client.cache.messages.has(message.id))
|
|
152
|
+
if (!this.client.cache.messages.has(message.id))
|
|
153
|
+
return;
|
|
147
154
|
const id = this.client.cache.messages.get(message.id);
|
|
148
|
-
if (!id)
|
|
155
|
+
if (!id)
|
|
156
|
+
return;
|
|
149
157
|
(async () => {
|
|
150
158
|
const msg = await message.channel.messages.fetch(id);
|
|
151
159
|
await msg.delete();
|
|
@@ -156,24 +164,25 @@ export default class CommandHandler extends Handler {
|
|
|
156
164
|
if (message.content && this.client.modules.options.message) {
|
|
157
165
|
const commands = this.client.commands.message;
|
|
158
166
|
const prefixes = Array.isArray(this.client.modules.options.message.prefix) ? this.client.modules.options.message.prefix : [this.client.modules.options.message.prefix];
|
|
159
|
-
let commandName = null,
|
|
160
|
-
cmd,
|
|
161
|
-
commandAlias = null,
|
|
162
|
-
commandPrefix = null;
|
|
167
|
+
let commandName = null, cmd, commandAlias = null, commandPrefix = null;
|
|
163
168
|
commands.map((command) => {
|
|
164
169
|
let prefix = null;
|
|
165
170
|
if (command.regex && message.content.match(command.regex)) {
|
|
166
171
|
const [match] = message.content.match(command.regex) || [null];
|
|
167
|
-
if (match)
|
|
172
|
+
if (match)
|
|
173
|
+
commandName = command.name;
|
|
168
174
|
}
|
|
169
175
|
const cp = Array.isArray(command.prefix) ? command.prefix : [command.prefix];
|
|
170
176
|
prefixes.map((p) => {
|
|
171
|
-
if (message.content.startsWith(p))
|
|
177
|
+
if (message.content.startsWith(p))
|
|
178
|
+
prefix = p;
|
|
172
179
|
});
|
|
173
180
|
cp.map((p) => {
|
|
174
|
-
if (message.content.startsWith(p))
|
|
181
|
+
if (message.content.startsWith(p))
|
|
182
|
+
prefix = p;
|
|
175
183
|
});
|
|
176
|
-
if (!prefix)
|
|
184
|
+
if (!prefix)
|
|
185
|
+
return;
|
|
177
186
|
if (!commandName)
|
|
178
187
|
commandName =
|
|
179
188
|
message.content
|
|
@@ -194,9 +203,12 @@ export default class CommandHandler extends Handler {
|
|
|
194
203
|
commandName = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift()?.toLowerCase() || null;
|
|
195
204
|
}
|
|
196
205
|
}
|
|
197
|
-
if (this.client.commands.message.has(commandName))
|
|
198
|
-
|
|
199
|
-
if (
|
|
206
|
+
if (this.client.commands.message.has(commandName))
|
|
207
|
+
cmd = this.client.commands.message.get(commandName);
|
|
208
|
+
if (await inhibitorValidation(message, cmd))
|
|
209
|
+
return;
|
|
210
|
+
if (!cmd)
|
|
211
|
+
return this.client.emit('commandNotFound', message, filetype);
|
|
200
212
|
message.util.parsed = {
|
|
201
213
|
alias: commandAlias,
|
|
202
214
|
prefix: commandPrefix,
|
|
@@ -210,20 +222,25 @@ export default class CommandHandler extends Handler {
|
|
|
210
222
|
interaction.util = new InteractionUtil(this.client, interaction);
|
|
211
223
|
interaction.user = await xernerxUser(interaction, this.client);
|
|
212
224
|
let cmd = null;
|
|
213
|
-
if (this.client.commands.slash.has(interaction.commandName))
|
|
214
|
-
|
|
215
|
-
if (
|
|
225
|
+
if (this.client.commands.slash.has(interaction.commandName))
|
|
226
|
+
cmd = this.client.commands.slash.get(interaction.commandName);
|
|
227
|
+
if (await inhibitorValidation(interaction, cmd))
|
|
228
|
+
return;
|
|
229
|
+
if (!cmd)
|
|
230
|
+
return this.client.emit('commandNotFound', interaction);
|
|
216
231
|
new Promise(async (resolve) => {
|
|
217
232
|
if (interaction.isAutocomplete()) {
|
|
218
233
|
const focused = interaction.options.getFocused(true);
|
|
219
234
|
const options = interaction.options;
|
|
220
235
|
await cmd.autocomplete(interaction, focused, options);
|
|
221
|
-
}
|
|
236
|
+
}
|
|
237
|
+
else
|
|
238
|
+
resolve(true);
|
|
222
239
|
})
|
|
223
240
|
.then(async () => {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
241
|
+
this.client.emit('commandStart', interaction, filetype);
|
|
242
|
+
await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
|
|
243
|
+
})
|
|
227
244
|
.catch((error) => this.client.emit('commandError', interaction, error, filetype));
|
|
228
245
|
}
|
|
229
246
|
async contextCommandRun(interaction) {
|
|
@@ -231,19 +248,25 @@ export default class CommandHandler extends Handler {
|
|
|
231
248
|
interaction.util = new InteractionUtil(this.client, interaction);
|
|
232
249
|
interaction.user = await xernerxUser(interaction, this.client);
|
|
233
250
|
let cmd;
|
|
234
|
-
if (this.client.commands.context.has(interaction.commandName))
|
|
235
|
-
|
|
236
|
-
if (
|
|
251
|
+
if (this.client.commands.context.has(interaction.commandName))
|
|
252
|
+
cmd = this.client.commands.context.get(interaction.commandName);
|
|
253
|
+
if (await inhibitorValidation(interaction, cmd))
|
|
254
|
+
return;
|
|
255
|
+
if (!cmd)
|
|
256
|
+
return this.client.emit('commandNotFound', interaction, filetype);
|
|
237
257
|
this.client.emit('commandStart', interaction, filetype);
|
|
238
258
|
this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
|
|
239
259
|
}
|
|
240
260
|
async exec(cmd, event, args, type) {
|
|
241
261
|
try {
|
|
242
|
-
if (await commandValidation(event, cmd))
|
|
243
|
-
|
|
262
|
+
if (await commandValidation(event, cmd))
|
|
263
|
+
return;
|
|
264
|
+
if (cmd.conditions && (await cmd.conditions(event, args)))
|
|
265
|
+
return;
|
|
244
266
|
cmd.exec(event, args);
|
|
245
267
|
this.client.emit('commandFinish', event, type);
|
|
246
|
-
}
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
247
270
|
new XernerxLog(this.client).error(`An error occurred executing ${cmd.name}`, error);
|
|
248
271
|
this.client.emit('commandError', event, error, type);
|
|
249
272
|
}
|
|
@@ -9,8 +9,8 @@ export default class EventHandler extends Handler {
|
|
|
9
9
|
async loadEvents(options) {
|
|
10
10
|
options = z
|
|
11
11
|
.object({
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
directory: z.string(),
|
|
13
|
+
})
|
|
14
14
|
.parse(options);
|
|
15
15
|
this.client.modules.options.events = options;
|
|
16
16
|
const files = this.readdir(options.directory);
|
|
@@ -7,12 +7,14 @@ export default class ExtensionHandler extends Handler {
|
|
|
7
7
|
loadExtensions(...extensions) {
|
|
8
8
|
const active = extensions.map((extension) => {
|
|
9
9
|
try {
|
|
10
|
-
if (extension.main)
|
|
10
|
+
if (extension.main)
|
|
11
|
+
extension.main(this.client);
|
|
11
12
|
if (extension.defer) {
|
|
12
13
|
this.client.on('ready', (client) => extension.defer(client));
|
|
13
14
|
}
|
|
14
15
|
return extension.name;
|
|
15
|
-
}
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
16
18
|
new XernerxLog(this.client).error(`An error occurred while loading ${extension.name}`, error);
|
|
17
19
|
}
|
|
18
20
|
});
|
package/dist/handlers/Handler.js
CHANGED
|
@@ -13,7 +13,8 @@ export default class Handler {
|
|
|
13
13
|
readdir(dir) {
|
|
14
14
|
try {
|
|
15
15
|
return fs.readdirSync(path.resolve(dir)).filter((file) => file.endsWith('.js'));
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
17
18
|
console.error(error);
|
|
18
19
|
}
|
|
19
20
|
return [];
|
|
@@ -24,13 +25,22 @@ export default class Handler {
|
|
|
24
25
|
return file;
|
|
25
26
|
}
|
|
26
27
|
async emit(event) {
|
|
27
|
-
if (!event?.fileType)
|
|
28
|
+
if (!event?.fileType)
|
|
29
|
+
return;
|
|
28
30
|
if (event.fileType === 'Event') {
|
|
29
|
-
if (event.emitter === 'client')
|
|
30
|
-
|
|
31
|
+
if (event.emitter === 'client')
|
|
32
|
+
event.once
|
|
33
|
+
? this.client.once(event.name, (...args) => event.run(...args))
|
|
34
|
+
: this.client.on(event.name, (...args) => event.run(...args));
|
|
35
|
+
else if (event.emitter === 'process')
|
|
36
|
+
event.once
|
|
37
|
+
? process.once(event.name, (...args) => event.run(...args))
|
|
38
|
+
: process.on(event.name, (...args) => event.run(...args));
|
|
31
39
|
}
|
|
32
40
|
if (['MessageCommand', 'SlashCommand', 'ContextCommand'].includes(event.fileType)) {
|
|
33
|
-
event.once
|
|
41
|
+
event.once
|
|
42
|
+
? this.client.once(event.name, (...args) => event.run(...args))
|
|
43
|
+
: this.client.on(event.name, (...args) => event.run(...args));
|
|
34
44
|
}
|
|
35
45
|
}
|
|
36
46
|
}
|
|
@@ -9,8 +9,8 @@ export default class InhibitorHandler extends Handler {
|
|
|
9
9
|
async loadInhibitors(options) {
|
|
10
10
|
options = z
|
|
11
11
|
.object({
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
directory: z.string(),
|
|
13
|
+
})
|
|
14
14
|
.parse(options);
|
|
15
15
|
this.client.modules.options.inhibitors = options;
|
|
16
16
|
const files = this.readdir(options.directory);
|
|
@@ -2,6 +2,8 @@ import XernerxClient from '../client/XernerxClient.js';
|
|
|
2
2
|
import Handler from './Handler.js';
|
|
3
3
|
export default class WebhookHandler extends Handler {
|
|
4
4
|
constructor(client: XernerxClient);
|
|
5
|
-
loadWebhooks(options: {
|
|
5
|
+
loadWebhooks(options: {
|
|
6
|
+
token: string;
|
|
7
|
+
}): Promise<void>;
|
|
6
8
|
private post;
|
|
7
9
|
}
|
|
@@ -11,13 +11,9 @@ export default class WebhookHandler extends Handler {
|
|
|
11
11
|
this.post(client.token);
|
|
12
12
|
}, 60000 * 30);
|
|
13
13
|
this.client.util.hasVoted = async (userId) => {
|
|
14
|
-
return !!(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
headers: { Authorization: options.token, 'Content-Type': 'application/json' },
|
|
18
|
-
})
|
|
19
|
-
).json()
|
|
20
|
-
).voted;
|
|
14
|
+
return !!(await (await fetch(`https://top.gg/api/bots/${this.client.user?.id}/check?userId=${userId}`, {
|
|
15
|
+
headers: { Authorization: options.token, 'Content-Type': 'application/json' },
|
|
16
|
+
})).json()).voted;
|
|
21
17
|
};
|
|
22
18
|
});
|
|
23
19
|
}
|
|
@@ -42,7 +38,8 @@ export default class WebhookHandler extends Handler {
|
|
|
42
38
|
shard_count: this.client.stats.shardCount,
|
|
43
39
|
}),
|
|
44
40
|
});
|
|
45
|
-
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
46
43
|
new XernerxLog(this.client).error(`An error occurred while posting stats to Top.gg`, error);
|
|
47
44
|
return this.client.emit('webhookError', this.client, this.client.stats);
|
|
48
45
|
}
|
package/dist/main.d.ts
CHANGED
|
@@ -12,31 +12,24 @@ import ExtensionBuilder from 'xernerx-extension-builder';
|
|
|
12
12
|
import Discord from 'discord.js';
|
|
13
13
|
declare const version: any;
|
|
14
14
|
export default XernerxClient;
|
|
15
|
-
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
-
version,
|
|
38
|
-
/**
|
|
39
|
-
** Tools
|
|
40
|
-
*/
|
|
41
|
-
XernerxLog,
|
|
42
|
-
};
|
|
15
|
+
export {
|
|
16
|
+
/**
|
|
17
|
+
** Clients
|
|
18
|
+
*/
|
|
19
|
+
XernerxClient, XernerxShardClient,
|
|
20
|
+
/**
|
|
21
|
+
** Builders
|
|
22
|
+
*/
|
|
23
|
+
MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder,
|
|
24
|
+
/**
|
|
25
|
+
** Imported exports
|
|
26
|
+
*/
|
|
27
|
+
Discord,
|
|
28
|
+
/**
|
|
29
|
+
** Properties
|
|
30
|
+
*/
|
|
31
|
+
version,
|
|
32
|
+
/**
|
|
33
|
+
** Tools
|
|
34
|
+
*/
|
|
35
|
+
XernerxLog, };
|
package/dist/main.js
CHANGED
|
@@ -13,31 +13,24 @@ import ExtensionBuilder from 'xernerx-extension-builder';
|
|
|
13
13
|
import Discord from 'discord.js';
|
|
14
14
|
const version = JSON.parse(fs.readFileSync('node_modules/xernerx/package.json', 'utf-8')).version;
|
|
15
15
|
export default XernerxClient;
|
|
16
|
-
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*/
|
|
38
|
-
version,
|
|
39
|
-
/**
|
|
40
|
-
** Tools
|
|
41
|
-
*/
|
|
42
|
-
XernerxLog,
|
|
43
|
-
};
|
|
16
|
+
export {
|
|
17
|
+
/**
|
|
18
|
+
** Clients
|
|
19
|
+
*/
|
|
20
|
+
XernerxClient, XernerxShardClient,
|
|
21
|
+
/**
|
|
22
|
+
** Builders
|
|
23
|
+
*/
|
|
24
|
+
MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder,
|
|
25
|
+
/**
|
|
26
|
+
** Imported exports
|
|
27
|
+
*/
|
|
28
|
+
Discord,
|
|
29
|
+
/**
|
|
30
|
+
** Properties
|
|
31
|
+
*/
|
|
32
|
+
version,
|
|
33
|
+
/**
|
|
34
|
+
** Tools
|
|
35
|
+
*/
|
|
36
|
+
XernerxLog, };
|