xernerx 4.5.6 → 4.5.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/XernerxContextCommand.d.ts +46 -44
- package/dist/build/XernerxContextCommand.js +64 -62
- package/dist/build/XernerxEvent.d.ts +16 -14
- package/dist/build/XernerxEvent.js +21 -19
- package/dist/build/XernerxInhibitor.d.ts +19 -17
- package/dist/build/XernerxInhibitor.js +13 -11
- package/dist/build/XernerxMessageCommand.d.ts +44 -42
- package/dist/build/XernerxMessageCommand.js +58 -56
- package/dist/build/XernerxSlashCommand.d.ts +56 -54
- package/dist/build/XernerxSlashCommand.js +110 -108
- package/dist/client/XernerxClient.d.ts +46 -44
- package/dist/client/XernerxClient.js +75 -73
- package/dist/client/XernerxShardClient.d.ts +12 -10
- package/dist/client/XernerxShardClient.js +50 -48
- package/dist/functions/deploy.d.ts +2 -0
- package/dist/functions/deploy.js +32 -30
- package/dist/functions/load.d.ts +2 -0
- package/dist/functions/load.js +29 -27
- package/dist/functions/reload.d.ts +2 -0
- package/dist/functions/reload.js +36 -34
- package/dist/functions/sendWebhook.d.ts +2 -0
- package/dist/functions/sendWebhook.js +12 -10
- package/dist/functions/setPresence.d.ts +2 -0
- package/dist/functions/setPresence.js +19 -17
- package/dist/functions/xernerxUser.d.ts +2 -0
- package/dist/functions/xernerxUser.js +10 -8
- package/dist/handlers/CommandHandler.d.ts +10 -8
- package/dist/handlers/CommandHandler.js +241 -239
- package/dist/handlers/EventHandler.d.ts +4 -2
- package/dist/handlers/EventHandler.js +20 -18
- package/dist/handlers/ExtensionHandler.d.ts +4 -2
- package/dist/handlers/ExtensionHandler.js +19 -17
- package/dist/handlers/Handler.d.ts +9 -7
- package/dist/handlers/Handler.js +33 -31
- package/dist/handlers/InhibitorHandler.d.ts +4 -2
- package/dist/handlers/InhibitorHandler.js +20 -18
- package/dist/handlers/WebhookHandler.d.ts +5 -3
- package/dist/handlers/WebhookHandler.js +48 -46
- package/dist/main.d.ts +28 -26
- package/dist/main.js +28 -26
- package/dist/models/Arguments.d.ts +4 -2
- package/dist/models/Arguments.js +136 -134
- package/dist/tools/XernerxError.d.ts +6 -4
- package/dist/tools/XernerxError.js +10 -8
- package/dist/tools/XernerxLog.d.ts +14 -12
- package/dist/tools/XernerxLog.js +77 -80
- package/dist/types/extenders.d.ts +13 -11
- package/dist/types/extenders.js +2 -0
- package/dist/types/interfaces.d.ts +184 -172
- package/dist/types/interfaces.d.ts.map +1 -1
- package/dist/types/interfaces.js +2 -0
- package/dist/types/interfaces.js.map +1 -1
- package/dist/types/types.d.ts +173 -171
- package/dist/types/types.js +2 -0
- package/dist/utils/ClientUtil.d.ts +8 -5
- package/dist/utils/ClientUtil.d.ts.map +1 -1
- package/dist/utils/ClientUtil.js +45 -26
- package/dist/utils/ClientUtil.js.map +1 -1
- package/dist/utils/InteractionUtil.d.ts +11 -5
- package/dist/utils/InteractionUtil.d.ts.map +1 -1
- package/dist/utils/InteractionUtil.js +98 -8
- package/dist/utils/InteractionUtil.js.map +1 -1
- package/dist/utils/MessageUtil.d.ts +14 -9
- package/dist/utils/MessageUtil.d.ts.map +1 -1
- package/dist/utils/MessageUtil.js +131 -37
- package/dist/utils/MessageUtil.js.map +1 -1
- package/dist/utils/Util.d.ts +5 -3
- package/dist/utils/Util.js +9 -7
- package/dist/validators/commandValidation.d.ts +4 -2
- package/dist/validators/commandValidation.js +44 -42
- package/dist/validators/inhibitorValidations.d.ts +16 -14
- package/dist/validators/inhibitorValidations.js +32 -30
- package/package.json +1 -1
|
@@ -1,54 +1,56 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
import { ShardingManager } from 'discord.js';
|
|
2
4
|
import XernerxLog from '../tools/XernerxLog.js';
|
|
3
5
|
import { Style } from 'dumfunctions';
|
|
4
6
|
export default class XernerxShardClient extends ShardingManager {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
7
|
+
constructor(file, discordOptions, xernerxOptions) {
|
|
8
|
+
super(file, discordOptions);
|
|
9
|
+
this.stats = { guildCount: 0, userCount: 0, shardCount: 0 };
|
|
10
|
+
this.user = null;
|
|
11
|
+
this.on('shardCreate', async (shard) => {
|
|
12
|
+
shard
|
|
13
|
+
.on('ready', async () => {
|
|
14
|
+
const guilds = await shard.fetchClientValue('guilds.cache');
|
|
15
|
+
const guildCount = guilds.length;
|
|
16
|
+
const userCount = guilds.map((guild) => guild.memberCount).length ? guilds.map((guild) => guild.memberCount).reduce((a, b) => (a += b)) : 0;
|
|
17
|
+
this.user = await shard.fetchClientValue('user');
|
|
18
|
+
this.stats.guildCount += Number(guildCount);
|
|
19
|
+
this.stats.userCount += Number(userCount);
|
|
20
|
+
this.stats.shardCount++;
|
|
21
|
+
await new XernerxLog({ settings: xernerxOptions }).info(
|
|
22
|
+
`Launched shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(this.user?.tag, { color: Style.TextColor.Blue })}!`
|
|
23
|
+
);
|
|
24
|
+
})
|
|
25
|
+
.on('error', (error) => {
|
|
26
|
+
new XernerxLog({ settings: xernerxOptions }).info(
|
|
27
|
+
`An error occurred in ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(String(this.user?.tag), { color: Style.TextColor.Blue })}! ${error}`
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
const spawn = this.spawn();
|
|
32
|
+
spawn.then(async (shards) => {
|
|
33
|
+
const collector = setInterval(() => {
|
|
34
|
+
const index = shards.size - 1;
|
|
35
|
+
if (shards.get(index)?.ready) {
|
|
36
|
+
new XernerxLog({ settings: xernerxOptions }).info(
|
|
37
|
+
`All Shards launched for ${Style.log(String(this.user?.tag), {
|
|
38
|
+
color: Style.TextColor.Blue,
|
|
39
|
+
})} with a total of ${Style.log(String(this.stats.shardCount), { color: Style.TextColor.Cyan })} shard${this.stats.shardCount > 1 ? 's' : ''}, watching ${Style.log(
|
|
40
|
+
String(this.stats.guildCount),
|
|
41
|
+
{
|
|
42
|
+
color: Style.TextColor.Cyan,
|
|
43
|
+
}
|
|
44
|
+
)} guild${this.stats.guildCount > 1 ? 's' : ''}, and ${Style.log(String(this.stats.userCount), { color: Style.TextColor.Cyan })} user${this.stats.userCount > 1 ? 's' : ''}!`
|
|
45
|
+
);
|
|
46
|
+
clearInterval(collector);
|
|
47
|
+
}
|
|
48
|
+
}, 1000);
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
shards: spawn,
|
|
52
|
+
stats: this.stats,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
53
55
|
}
|
|
54
56
|
//# sourceMappingURL=XernerxShardClient.js.map
|
package/dist/functions/deploy.js
CHANGED
|
@@ -1,40 +1,42 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
import { GatewayVersion, REST, Routes } from 'discord.js';
|
|
2
4
|
import XernerxLog from '../tools/XernerxLog.js';
|
|
3
5
|
import XernerxError from '../tools/XernerxError.js';
|
|
4
6
|
import { Style } from 'dumfunctions';
|
|
5
7
|
const commands = [];
|
|
6
8
|
export default function deploy(client) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
9
|
+
client.prependOnceListener('ready', (client) => {
|
|
10
|
+
if (client.commands.slash.size) client.commands.slash.map((command) => commands.push(command.data.toJSON()));
|
|
11
|
+
if (client.commands.context.size) client.commands.context.map((command) => commands.push(command.data.toJSON()));
|
|
12
|
+
if (commands.length <= 0) return;
|
|
13
|
+
try {
|
|
14
|
+
if (client.settings.global) {
|
|
15
|
+
put(client, client.settings.global, commands);
|
|
16
|
+
put(client, !client.settings.global, []);
|
|
17
|
+
} else {
|
|
18
|
+
put(client, !client.settings.global, commands);
|
|
19
|
+
put(client, client.settings.global, []);
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
new XernerxLog(client).error(`An error occurred while deploying the interaction commands!`, error);
|
|
23
|
+
} finally {
|
|
24
|
+
new XernerxLog(client).info(
|
|
25
|
+
`Deployed ${Style.log(String([client.commands.message.size, client.commands.slash.size, client.commands.context.size].reduce((a, b) => (a += b))), {
|
|
26
|
+
color: Style.TextColor.Cyan,
|
|
27
|
+
})} Commands ${
|
|
28
|
+
client.settings.global
|
|
29
|
+
? Style.log('globally', { color: Style.TextColor.Green })
|
|
30
|
+
: `${Style.log('locally', { color: Style.TextColor.Red })} in ${Style.log(client.guilds.cache.get(client.settings.local).name, { color: Style.TextColor.Blue })}`
|
|
31
|
+
}.`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
33
35
|
}
|
|
34
36
|
function put(client, global, body) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const rest = new REST({ version: GatewayVersion }).setToken(client.token);
|
|
38
|
+
if (!global && !client.settings?.local) throw new XernerxError(`No guild ID provided as local guild!`);
|
|
39
|
+
if (!global && client.settings?.local) rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
|
|
40
|
+
else rest.put(Routes.applicationCommands(client.user?.id), { body });
|
|
39
41
|
}
|
|
40
42
|
//# sourceMappingURL=deploy.js.map
|
package/dist/functions/load.d.ts
CHANGED
package/dist/functions/load.js
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
import XernerxLog from '../tools/XernerxLog.js';
|
|
2
4
|
export default async function load(client, path, type) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
try {
|
|
6
|
+
let file = new (await import(`file://${path}`)).default();
|
|
7
|
+
file.fileType = type;
|
|
8
|
+
file.filePath = path;
|
|
9
|
+
file.client = client;
|
|
10
|
+
fileSave(client, file, type);
|
|
11
|
+
return file;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
new XernerxLog(client).error(`Couldn't load ${type} ${path.match(/\w*\.js$/gim)?.at(0) || path}`, error);
|
|
14
|
+
}
|
|
13
15
|
}
|
|
14
16
|
function fileSave(client, file, type) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
switch (type) {
|
|
18
|
+
case 'MessageCommand':
|
|
19
|
+
client.commands.message.set(file.name, file);
|
|
20
|
+
break;
|
|
21
|
+
case 'SlashCommand':
|
|
22
|
+
client.commands.slash.set(file.name, file);
|
|
23
|
+
break;
|
|
24
|
+
case 'ContextCommand':
|
|
25
|
+
client.commands.context.set(file.name, file);
|
|
26
|
+
break;
|
|
27
|
+
case 'Inhibitor':
|
|
28
|
+
client.inhibitors.set(file.name, file);
|
|
29
|
+
break;
|
|
30
|
+
case 'Event':
|
|
31
|
+
client.events.set(file.name, file);
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
35
|
//# sourceMappingURL=load.js.map
|
package/dist/functions/reload.js
CHANGED
|
@@ -1,40 +1,42 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
var FileTypes;
|
|
2
4
|
(function (FileTypes) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
FileTypes['message'] = 'MessageCommand';
|
|
6
|
+
FileTypes['slash'] = 'SlashCommand';
|
|
7
|
+
FileTypes['context'] = 'ContextCommand';
|
|
8
|
+
FileTypes['event'] = 'Event';
|
|
9
|
+
FileTypes['inhibitor'] = 'Inhibitor';
|
|
8
10
|
})(FileTypes || (FileTypes = {}));
|
|
9
11
|
export default function reload(client, type) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
12
|
+
const files = [];
|
|
13
|
+
if (type === 'message' || type === 'slash' || type === 'context') {
|
|
14
|
+
for (const [name] of client.commands[type]) {
|
|
15
|
+
files.push(client.commands[type].get(name).filePath);
|
|
16
|
+
}
|
|
17
|
+
client.commands[type].sweep(() => true);
|
|
18
|
+
}
|
|
19
|
+
if (type === 'event') {
|
|
20
|
+
for (const [name] of client.events) {
|
|
21
|
+
files.push(client.events.get(name).filePath);
|
|
22
|
+
}
|
|
23
|
+
client.events.sweep(() => true);
|
|
24
|
+
}
|
|
25
|
+
if (type === 'inhibitor') {
|
|
26
|
+
for (const [name] of client.inhibitors) {
|
|
27
|
+
files.push(client.inhibitors.get(name).filePath);
|
|
28
|
+
}
|
|
29
|
+
client.inhibitors.sweep(() => true);
|
|
30
|
+
}
|
|
31
|
+
return files.map(async (file) => {
|
|
32
|
+
let filedata = new (await import(`file://${file}`)).default();
|
|
33
|
+
filedata.fileType = FileTypes[type];
|
|
34
|
+
filedata.filePath = file;
|
|
35
|
+
filedata.client = client;
|
|
36
|
+
if (type === 'message' || type === 'slash' || type === 'context') client.commands[type].set(filedata.name, filedata);
|
|
37
|
+
if (type === 'event') client.events.set(filedata.name, filedata);
|
|
38
|
+
if (type === 'inhibitor') client.inhibitors.set(filedata.name, filedata);
|
|
39
|
+
return filedata;
|
|
40
|
+
});
|
|
39
41
|
}
|
|
40
42
|
//# sourceMappingURL=reload.js.map
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
export default async function sendWebhook(url, body) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const response = await fetch(url, {
|
|
5
|
+
method: 'POST',
|
|
6
|
+
headers: {
|
|
7
|
+
'Content-Type': 'application/json',
|
|
8
|
+
},
|
|
9
|
+
body: JSON.stringify(body),
|
|
10
|
+
});
|
|
11
|
+
if (response.status === 204) return true;
|
|
12
|
+
const data = await response.json();
|
|
13
|
+
return data;
|
|
12
14
|
}
|
|
13
15
|
//# sourceMappingURL=sendWebhook.js.map
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
export default function setPresence(client, options) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
const presence = () =>
|
|
5
|
+
client.user?.setPresence({
|
|
6
|
+
activities: [
|
|
7
|
+
{
|
|
8
|
+
name: options.text,
|
|
9
|
+
type: options.type,
|
|
10
|
+
url: options.url,
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
status: options.status,
|
|
14
|
+
});
|
|
15
|
+
let response = presence();
|
|
16
|
+
if (options.interval)
|
|
17
|
+
setInterval(() => {
|
|
18
|
+
response = presence();
|
|
19
|
+
}, options.interval);
|
|
20
|
+
return response;
|
|
19
21
|
}
|
|
20
22
|
//# sourceMappingURL=setPresence.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
import XernerxClient from '../client/XernerxClient.js';
|
|
2
4
|
import { XernerxMessage, XernerxSlashInteraction, XernerxUser, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
3
5
|
export declare function xernerxUser(event: XernerxMessage | XernerxSlashInteraction | XernerxUserContextInteraction | XernerxUserContextInteraction, client: XernerxClient): Promise<XernerxUser>;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
export async function xernerxUser(event, client) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const author = event.author || event.user;
|
|
5
|
+
const user = {
|
|
6
|
+
...author,
|
|
7
|
+
owner: isOwner(client, author),
|
|
8
|
+
voted: client.util.hasVoted ? await client.util.hasVoted(author.id) : null,
|
|
9
|
+
};
|
|
10
|
+
return user;
|
|
9
11
|
}
|
|
10
12
|
function isOwner(client, user) {
|
|
11
|
-
|
|
13
|
+
return client.settings.ownerId.includes(user.id);
|
|
12
14
|
}
|
|
13
15
|
//# sourceMappingURL=xernerxUser.js.map
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
import XernerxClient from '../client/XernerxClient.js';
|
|
2
4
|
import { ContextHandlerOptions, MessageHandlerOptions, SlashHandlerOptions } from '../types/interfaces.js';
|
|
3
5
|
import Handler from './Handler.js';
|
|
4
6
|
export default class CommandHandler extends Handler {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
constructor(client: XernerxClient);
|
|
8
|
+
loadMessageCommands(options: MessageHandlerOptions): void;
|
|
9
|
+
loadSlashCommands(options: SlashHandlerOptions): void;
|
|
10
|
+
loadContextCommands(options: ContextHandlerOptions): void;
|
|
11
|
+
private messageCommandRun;
|
|
12
|
+
private slashCommandRun;
|
|
13
|
+
private contextCommandRun;
|
|
14
|
+
private exec;
|
|
13
15
|
}
|
|
14
16
|
//# sourceMappingURL=CommandHandler.d.ts.map
|