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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export async function messageArguments(message, command) {
|
|
2
|
+
const separator = command.separator || ' ',
|
|
3
|
+
content = message.content.split(separator).slice(1);
|
|
4
|
+
let args = {},
|
|
5
|
+
flags = {};
|
|
6
|
+
if (command.flags)
|
|
7
|
+
command.flags.map((flag) => {
|
|
8
|
+
if (!flags) flags = {};
|
|
9
|
+
if (content.includes(flag.match)) flags[flag.name] = true;
|
|
10
|
+
else flags[flag.name] = false;
|
|
11
|
+
const index = content.indexOf(flag.match);
|
|
12
|
+
if (index > 0) content.splice(index, 1);
|
|
13
|
+
});
|
|
14
|
+
if (command.args)
|
|
15
|
+
for (const argument of command.args) {
|
|
16
|
+
const element = content.at(0) || null;
|
|
17
|
+
if (!element) {
|
|
18
|
+
if (typeof argument.default === 'function') args[argument.name] = argument.default(message);
|
|
19
|
+
args[argument.name] = argument.default || null;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (argument.type === 'option') argument.match?.includes(element) ? (args[argument.name] = element) : (args[argument.name] = null);
|
|
23
|
+
if (argument.type === 'number') args[argument.name] = parseInt(element);
|
|
24
|
+
if (argument.type === 'integer') args[argument.name] = parseInt(element);
|
|
25
|
+
if (argument.type === 'boolean') args[argument.name] = element === 'true' ? true : false;
|
|
26
|
+
if (argument.type === 'confirm') args[argument.name] = element === 'yes' ? 'yes' : 'no';
|
|
27
|
+
if (argument.type === 'string') args[argument.name] = element;
|
|
28
|
+
if (argument.type === 'channel') {
|
|
29
|
+
try {
|
|
30
|
+
const channel = await message.client.channels.fetch(element);
|
|
31
|
+
args[argument.name] = channel;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
args[argument.name] = null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (argument.type === 'guild') {
|
|
37
|
+
try {
|
|
38
|
+
const guild = await message.client.guilds.fetch(element);
|
|
39
|
+
args[argument.name] = guild;
|
|
40
|
+
} catch (e) {
|
|
41
|
+
args[argument.name] = null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (argument.type === 'mentionable') {
|
|
45
|
+
(
|
|
46
|
+
await Promise.all(
|
|
47
|
+
[message.guild?.roles, message.client.users, message.client.guilds, message.client.channels, message.guild?.members, message.channel.messages].map((req) =>
|
|
48
|
+
req
|
|
49
|
+
? req
|
|
50
|
+
.fetch(element)
|
|
51
|
+
.then((r) => r)
|
|
52
|
+
.catch(() => null)
|
|
53
|
+
: null
|
|
54
|
+
)
|
|
55
|
+
)
|
|
56
|
+
).map((mentionable) => {
|
|
57
|
+
if (!args) args = {};
|
|
58
|
+
if (mentionable) return (args[argument.name] = mentionable);
|
|
59
|
+
else args[argument.name] = null;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (argument.type === 'role') {
|
|
63
|
+
try {
|
|
64
|
+
const role = await message.guild?.roles.fetch(element);
|
|
65
|
+
args[argument.name] = role;
|
|
66
|
+
} catch (e) {
|
|
67
|
+
args[argument.name] = null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (argument.type === 'user') {
|
|
71
|
+
try {
|
|
72
|
+
const user = await message.client.users.fetch(element);
|
|
73
|
+
args[argument.name] = user;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
args[argument.name] = null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (argument.type === 'member') {
|
|
79
|
+
try {
|
|
80
|
+
const member = await message.guild?.members.fetch(element);
|
|
81
|
+
args[argument.name] = member;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
args[argument.name] = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (argument.type === 'message') {
|
|
87
|
+
try {
|
|
88
|
+
const msg = await message.channel?.messages.fetch(element);
|
|
89
|
+
args[argument.name] = msg;
|
|
90
|
+
} catch (e) {
|
|
91
|
+
args[argument.name] = null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (argument.type === 'list') {
|
|
95
|
+
let separator = String(argument.separator) || ',';
|
|
96
|
+
if (separator.startsWith('/') && separator.endsWith('/')) separator = separator.replace(/^\/|\/$/gim, '');
|
|
97
|
+
const items = content.join(' ').split(new RegExp(' *' + separator + ' *', 'gi'));
|
|
98
|
+
if (!argument.content) args[argument.name] = items;
|
|
99
|
+
else {
|
|
100
|
+
const contents = argument.content.map((content) => content.toLowerCase()),
|
|
101
|
+
itemList = [];
|
|
102
|
+
items.map((item) => (contents.includes(item.toLowerCase()) ? itemList.push(argument.content?.at(contents.indexOf(item.toLowerCase()))) : null));
|
|
103
|
+
args[argument.name] = itemList;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (argument.type === 'rest') {
|
|
108
|
+
args[argument.name] = content.join(separator);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
content.splice(0, 1);
|
|
112
|
+
}
|
|
113
|
+
if (!command.flags) flags = null;
|
|
114
|
+
if (!command.args) args = null;
|
|
115
|
+
return { args, flags };
|
|
116
|
+
}
|
|
117
|
+
export async function interactionArguments(interaction, command) {
|
|
118
|
+
const options = {};
|
|
119
|
+
let args = interaction?.options?._hoistedOptions,
|
|
120
|
+
group = interaction?.options?._group,
|
|
121
|
+
subcommand = interaction?.options?._subcommand;
|
|
122
|
+
if (interaction.options._hoistedOptions) {
|
|
123
|
+
for (const option of interaction.options._hoistedOptions) {
|
|
124
|
+
options[option.name] = option.member || option.channel || option.user || option.role || option.value;
|
|
125
|
+
}
|
|
126
|
+
args = options;
|
|
127
|
+
}
|
|
128
|
+
return { args, group, subcommand };
|
|
129
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.messageArguments = exports.InteractionArguments = void 0;
|
|
4
|
-
class InteractionArguments {
|
|
1
|
+
export class InteractionArguments {
|
|
5
2
|
interaction;
|
|
6
3
|
constructor(interaction) {
|
|
7
4
|
this.interaction = interaction;
|
|
@@ -22,8 +19,7 @@ class InteractionArguments {
|
|
|
22
19
|
return options;
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
async function messageArguments(message, command) {
|
|
22
|
+
export async function messageArguments(message, command) {
|
|
27
23
|
let args = { flags: {} },
|
|
28
24
|
separator = command.separator || ' ',
|
|
29
25
|
i = 0;
|
|
@@ -103,4 +99,3 @@ async function messageArguments(message, command) {
|
|
|
103
99
|
}
|
|
104
100
|
return args;
|
|
105
101
|
}
|
|
106
|
-
exports.messageArguments = messageArguments;
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 {
|
|
1
|
+
import { GatewayVersion, InteractionType, REST, Routes } from 'discord.js';
|
|
2
|
+
import { InteractionCommandUtil, MessageCommandUtil } from '../utils/CommandUtil.js';
|
|
3
|
+
import { InteractionArguments, messageArguments } from './CommandArguments.js';
|
|
4
|
+
import commandValidation from '../validators/CommandValidations.js';
|
|
5
|
+
import { Style } from 'dumfunctions';
|
|
6
|
+
import { InhibitorValidation } from '../validators/InhibitorValidations.js';
|
|
7
|
+
import User from './XernerxUser.js';
|
|
8
|
+
export class MessageCommandEvents {
|
|
16
9
|
client;
|
|
17
10
|
constructor(client) {
|
|
18
11
|
this.client = client;
|
|
@@ -22,8 +15,8 @@ class MessageCommandEvents {
|
|
|
22
15
|
if (!message.author.bot) {
|
|
23
16
|
let command = undefined,
|
|
24
17
|
px = undefined;
|
|
25
|
-
message.author
|
|
26
|
-
message.util = new
|
|
18
|
+
message.author = await User(message);
|
|
19
|
+
message.util = new MessageCommandUtil(this.client, message);
|
|
27
20
|
const commands = this.client.commands.message;
|
|
28
21
|
commands
|
|
29
22
|
.filter((c) => !c.regex)
|
|
@@ -58,11 +51,11 @@ class MessageCommandEvents {
|
|
|
58
51
|
) {
|
|
59
52
|
try {
|
|
60
53
|
if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
|
|
61
|
-
const inhibitor = new
|
|
62
|
-
if ((
|
|
54
|
+
const inhibitor = new InhibitorValidation(this.client, message, command);
|
|
55
|
+
if (commandValidation(message, cmd, this.client)) return;
|
|
63
56
|
if (await inhibitor.inhibit()) return;
|
|
64
|
-
if (cmd.conditions && (await cmd.conditions(message, await
|
|
65
|
-
await cmd.exec(message, await
|
|
57
|
+
if (cmd.conditions && (await cmd.conditions(message, await messageArguments(message, cmd)))) return;
|
|
58
|
+
await cmd.exec(message, await messageArguments(message, cmd));
|
|
66
59
|
this.client.emit('commandRun', message, cmd);
|
|
67
60
|
} catch (error) {
|
|
68
61
|
return this.client.emit('commandError', message, error, cmd);
|
|
@@ -78,8 +71,8 @@ class MessageCommandEvents {
|
|
|
78
71
|
if (!message.author?.bot) {
|
|
79
72
|
let command = undefined,
|
|
80
73
|
px = undefined;
|
|
81
|
-
|
|
82
|
-
message.util = new
|
|
74
|
+
message.author = await User(message);
|
|
75
|
+
message.util = new MessageCommandUtil(this.client, message);
|
|
83
76
|
const commands = this.client.commands.message;
|
|
84
77
|
commands
|
|
85
78
|
.filter((c) => !c.regex)
|
|
@@ -115,11 +108,11 @@ class MessageCommandEvents {
|
|
|
115
108
|
try {
|
|
116
109
|
if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
|
|
117
110
|
message = message;
|
|
118
|
-
const inhibitor = new
|
|
119
|
-
if ((
|
|
111
|
+
const inhibitor = new InhibitorValidation(this.client, message, command);
|
|
112
|
+
if (commandValidation(message, cmd, this.client)) return;
|
|
120
113
|
if (await inhibitor.inhibit()) return;
|
|
121
|
-
if (cmd.conditions && (await cmd.conditions(message, await
|
|
122
|
-
await cmd.exec(message, await
|
|
114
|
+
if (cmd.conditions && (await cmd.conditions(message, await messageArguments(message, cmd)))) return;
|
|
115
|
+
await cmd.exec(message, await messageArguments(message, cmd));
|
|
123
116
|
this.client.emit('commandRun', message, cmd);
|
|
124
117
|
} catch (error) {
|
|
125
118
|
return this.client.emit('commandError', message, error, cmd);
|
|
@@ -134,6 +127,7 @@ class MessageCommandEvents {
|
|
|
134
127
|
if (this.client.cache.messages.has(message.id) && this.client.handlerOptions.message?.handleDeletes) {
|
|
135
128
|
try {
|
|
136
129
|
if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
|
|
130
|
+
message.author = await User(message);
|
|
137
131
|
const msg = this.client.cache.messages.get(message.id);
|
|
138
132
|
const response = await message.channel.messages.fetch(msg?.response);
|
|
139
133
|
await response.delete();
|
|
@@ -144,24 +138,23 @@ class MessageCommandEvents {
|
|
|
144
138
|
});
|
|
145
139
|
}
|
|
146
140
|
}
|
|
147
|
-
|
|
148
|
-
class SlashCommandEvents {
|
|
141
|
+
export class SlashCommandEvents {
|
|
149
142
|
client;
|
|
150
143
|
constructor(client) {
|
|
151
144
|
this.client = client;
|
|
152
145
|
}
|
|
153
146
|
slashCreate() {
|
|
154
147
|
this.client.on('interactionCreate', async (interaction) => {
|
|
155
|
-
interaction.util = new
|
|
156
|
-
interaction.
|
|
157
|
-
if (interaction.type ===
|
|
148
|
+
interaction.util = new InteractionCommandUtil(this.client, interaction);
|
|
149
|
+
interaction.author = await User(interaction);
|
|
150
|
+
if (interaction.type === InteractionType.ApplicationCommand) {
|
|
158
151
|
if (this.client.commands.slash.has(interaction.commandName)) {
|
|
159
152
|
let command = this.client.commands.slash.get(interaction.commandName);
|
|
160
|
-
const argumentsInfo = new
|
|
153
|
+
const argumentsInfo = new InteractionArguments(interaction);
|
|
161
154
|
try {
|
|
162
|
-
const inhibitor = new
|
|
155
|
+
const inhibitor = new InhibitorValidation(this.client, interaction, command);
|
|
163
156
|
if (await inhibitor.inhibit()) return;
|
|
164
|
-
if ((
|
|
157
|
+
if (commandValidation(interaction, command, this.client)) return;
|
|
165
158
|
if (command.defer?.reply !== false && this.client.handlerOptions.slash?.defer?.reply)
|
|
166
159
|
await interaction.deferReply({
|
|
167
160
|
ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral,
|
|
@@ -195,22 +188,21 @@ class SlashCommandEvents {
|
|
|
195
188
|
});
|
|
196
189
|
}
|
|
197
190
|
}
|
|
198
|
-
|
|
199
|
-
class ContextCommandEvents {
|
|
191
|
+
export class ContextCommandEvents {
|
|
200
192
|
client;
|
|
201
193
|
constructor(client) {
|
|
202
194
|
this.client = client;
|
|
203
195
|
}
|
|
204
196
|
contextCreate() {
|
|
205
197
|
this.client.on('interactionCreate', async (interaction) => {
|
|
206
|
-
interaction.util = new
|
|
207
|
-
interaction.
|
|
208
|
-
if (interaction.type ===
|
|
198
|
+
interaction.util = new InteractionCommandUtil(this.client, interaction);
|
|
199
|
+
interaction.author = await User(interaction);
|
|
200
|
+
if (interaction.type === InteractionType.ApplicationCommand) {
|
|
209
201
|
if (this.client.commands.context.has(interaction.commandName)) {
|
|
210
202
|
let command = this.client.commands.context.get(interaction.commandName);
|
|
211
203
|
try {
|
|
212
|
-
const inhibitor = new
|
|
213
|
-
if ((
|
|
204
|
+
const inhibitor = new InhibitorValidation(this.client, interaction, command);
|
|
205
|
+
if (commandValidation(interaction, command, this.client)) return;
|
|
214
206
|
if (await inhibitor.inhibit()) return;
|
|
215
207
|
if (command.conditions && (await command.conditions(interaction))) return;
|
|
216
208
|
if (command.defer?.reply !== false && this.client.handlerOptions.context?.defer?.reply)
|
|
@@ -236,8 +228,7 @@ class ContextCommandEvents {
|
|
|
236
228
|
});
|
|
237
229
|
}
|
|
238
230
|
}
|
|
239
|
-
|
|
240
|
-
class CommandsDeploy {
|
|
231
|
+
export class CommandsDeploy {
|
|
241
232
|
client;
|
|
242
233
|
constructor(client) {
|
|
243
234
|
this.client = client;
|
|
@@ -261,11 +252,11 @@ class CommandsDeploy {
|
|
|
261
252
|
if (global.slash && global.context) {
|
|
262
253
|
if (guild.slash !== guild.context)
|
|
263
254
|
console.info(
|
|
264
|
-
|
|
255
|
+
Style.log(
|
|
265
256
|
`Xernerx | Warning: slash and context commands are both set to global, but don't have a matching guildId, using ${
|
|
266
257
|
(await this.client.guilds.fetch(this.client.handlerOptions.slash?.guildId)).name
|
|
267
258
|
}!`,
|
|
268
|
-
{ color:
|
|
259
|
+
{ color: Style.TextColor.Red }
|
|
269
260
|
)
|
|
270
261
|
);
|
|
271
262
|
this.put('global', guild.slash, [...contextCommands, ...slashCommands]);
|
|
@@ -282,26 +273,25 @@ class CommandsDeploy {
|
|
|
282
273
|
}
|
|
283
274
|
if (this.client.handlerOptions.context?.logging || this.client.handlerOptions.slash?.logging)
|
|
284
275
|
console.info(
|
|
285
|
-
|
|
276
|
+
Style.log(
|
|
286
277
|
`Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? 'globally' : 'locally'} and ${contextCommands.length} context commands ${
|
|
287
278
|
global.context ? 'globally' : 'locally'
|
|
288
279
|
}.`,
|
|
289
|
-
{ color:
|
|
280
|
+
{ color: Style.TextColor.Purple }
|
|
290
281
|
)
|
|
291
282
|
);
|
|
292
283
|
} catch (error) {
|
|
293
284
|
console.error(
|
|
294
|
-
|
|
295
|
-
color:
|
|
285
|
+
Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
|
|
286
|
+
color: Style.BackgroundColor.Red,
|
|
296
287
|
})
|
|
297
288
|
);
|
|
298
289
|
}
|
|
299
290
|
});
|
|
300
291
|
}
|
|
301
292
|
put(type, guild, body) {
|
|
302
|
-
const rest = new
|
|
303
|
-
if (type === 'guild') rest.put(
|
|
304
|
-
else rest.put(
|
|
293
|
+
const rest = new REST({ version: GatewayVersion }).setToken(this.client.token);
|
|
294
|
+
if (type === 'guild') rest.put(Routes.applicationGuildCommands(this.client.user?.id, guild), { body });
|
|
295
|
+
else rest.put(Routes.applicationCommands(this.client.user?.id), { body });
|
|
305
296
|
}
|
|
306
297
|
}
|
|
307
|
-
exports.CommandsDeploy = CommandsDeploy;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Style } from 'dumfunctions';
|
|
2
|
+
export default class Extensions {
|
|
3
|
+
client;
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
async load(extensions, logging = false) {
|
|
8
|
+
const exts = [];
|
|
9
|
+
extensions.map((extension) => {
|
|
10
|
+
try {
|
|
11
|
+
this.client.extensions[extension.name] = extension;
|
|
12
|
+
exts.push(extension.name);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.error(
|
|
15
|
+
Style.log(`Xernerx | An error occurred trying to load ${extension.name}, error: <${error}>`, {
|
|
16
|
+
color: Style.BackgroundColor.Red,
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
if (logging) console.info(Style.log(`Xernerx | Loaded ${exts.length} extensions: ${exts.join(', ')}`, { color: Style.TextColor.Cyan }));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { hasVoted } from 'dbl-sdk';
|
|
2
|
+
export default async function XernerxUser(interaction) {
|
|
3
|
+
const user = interaction.user || interaction.author;
|
|
4
|
+
user.owner = interaction.client.util.isOwner(user.id);
|
|
5
|
+
user.voter = interaction.client.handlerOptions?.webhook?.topgg?.token
|
|
6
|
+
? await hasVoted(user.id, interaction.client.user.id, interaction.client.handlerOptions.webhook.topgg.token, 'top.gg')
|
|
7
|
+
: false;
|
|
8
|
+
return user;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import XernerxError from './XernerxError.js';
|
|
2
|
+
import XernerxClient from '../client/XernerxClient.js';
|
|
3
|
+
export default class XernerxLog {
|
|
4
|
+
private readonly client;
|
|
5
|
+
private readonly errorLog;
|
|
6
|
+
private readonly infoLog;
|
|
7
|
+
private readonly readyLog;
|
|
8
|
+
constructor(client: XernerxClient);
|
|
9
|
+
info(message: string, force?: boolean): void | null;
|
|
10
|
+
warn(message: string): void | null;
|
|
11
|
+
error(message: string, error?: XernerxError | unknown): void | null;
|
|
12
|
+
ready(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Style } from 'dumfunctions';
|
|
2
|
+
export default class XernerxLog {
|
|
3
|
+
client;
|
|
4
|
+
errorLog;
|
|
5
|
+
infoLog;
|
|
6
|
+
readyLog;
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.errorLog = client.settings.log?.error;
|
|
10
|
+
this.infoLog = client.settings.log?.info;
|
|
11
|
+
this.readyLog = client.settings.log?.ready;
|
|
12
|
+
}
|
|
13
|
+
info(message, force = false) {
|
|
14
|
+
return this.infoLog || force ? console.info(`${Style.log('✔️ | Xernerx', { color: Style.TextColor.Purple })} | ${message}`) : null;
|
|
15
|
+
}
|
|
16
|
+
warn(message) {
|
|
17
|
+
return this.infoLog ? console.warn(`${Style.log('⚠️ | Xernerx', { color: Style.TextColor.Yellow })} | ${message}`) : null;
|
|
18
|
+
}
|
|
19
|
+
error(message, error) {
|
|
20
|
+
return this.errorLog ? console.error(`${Style.log('❗ | Xernerx', { color: Style.TextColor.Red })} | ${message}${error ? ` | ${error.stack}` : ''}`) : null;
|
|
21
|
+
}
|
|
22
|
+
ready() {
|
|
23
|
+
this.client.prependOnceListener('ready', async (synced) =>
|
|
24
|
+
this.info(
|
|
25
|
+
`${synced.user.tag} is now online, watching ${(await this.client.guilds.fetch()).size} guilds, using ${await this.client.guilds.fetch(this.client.settings.local)} as local guild.`,
|
|
26
|
+
this.readyLog
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
name: string;
|
|
3
3
|
version: string;
|
|
4
|
-
type: string;
|
|
5
4
|
description: string;
|
|
6
5
|
main: string;
|
|
6
|
+
module: string;
|
|
7
7
|
keywords: string[];
|
|
8
8
|
author: string;
|
|
9
9
|
license: string;
|
|
10
10
|
homepage: string;
|
|
11
11
|
packageManager: string;
|
|
12
|
-
exports: {
|
|
13
|
-
import: string;
|
|
14
|
-
require: string;
|
|
15
|
-
types: string;
|
|
16
|
-
node: null;
|
|
17
|
-
default: null;
|
|
18
|
-
};
|
|
19
12
|
scripts: {
|
|
20
13
|
start: string;
|
|
21
14
|
patch: string;
|
|
@@ -24,7 +17,10 @@ declare const _default: {
|
|
|
24
17
|
site: string;
|
|
25
18
|
commit: string;
|
|
26
19
|
write: string;
|
|
20
|
+
format: string;
|
|
27
21
|
build: string;
|
|
22
|
+
'build:esm': string;
|
|
23
|
+
'build:cjs': string;
|
|
28
24
|
};
|
|
29
25
|
repository: {
|
|
30
26
|
type: string;
|
|
@@ -35,6 +31,7 @@ declare const _default: {
|
|
|
35
31
|
};
|
|
36
32
|
dependencies: {
|
|
37
33
|
'@sapphire/shapeshift': string;
|
|
34
|
+
'dbl-sdk': string;
|
|
38
35
|
'discord.js': string;
|
|
39
36
|
dumfunctions: string;
|
|
40
37
|
'xernerx-extension-builder': string;
|
|
@@ -42,7 +39,6 @@ declare const _default: {
|
|
|
42
39
|
};
|
|
43
40
|
devDependencies: {
|
|
44
41
|
prettier: string;
|
|
45
|
-
tsup: string;
|
|
46
42
|
typescript: string;
|
|
47
43
|
};
|
|
48
44
|
};
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.default = {
|
|
1
|
+
export default {
|
|
4
2
|
name: 'xernerx',
|
|
5
|
-
version: '3.
|
|
6
|
-
type: 'module',
|
|
3
|
+
version: '3.6.0',
|
|
7
4
|
description: 'A bot framework for discord.js.',
|
|
8
|
-
main: 'dist/main.js',
|
|
5
|
+
main: 'dist/cjs/main.js',
|
|
6
|
+
module: 'dist/mjs/main.js',
|
|
9
7
|
keywords: ['discord.js', 'discord', 'framework', 'mjs', 'esm', 'cjs', 'ts'],
|
|
10
8
|
author: 'Dummi',
|
|
11
9
|
license: 'MIT',
|
|
12
10
|
homepage: 'https://xernerx.github.io/xernerx/home.html',
|
|
13
11
|
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
12
|
scripts: {
|
|
22
13
|
start: 'npm i && npm fund && npm audit fix --force && npm link && tsc -w',
|
|
23
14
|
patch: 'npm run write && git add . && npm run commit && npm version patch && npm publish && git push',
|
|
@@ -25,8 +16,11 @@ exports.default = {
|
|
|
25
16
|
major: 'npm run write && git add . && npm run commit && npm version major && npm publish && git push',
|
|
26
17
|
site: 'git add docs && npm run commit && git push',
|
|
27
18
|
commit: 'node ../.scripts/commit.js',
|
|
28
|
-
write: 'npm run build && node ../.scripts/rewritePackage.js ',
|
|
29
|
-
|
|
19
|
+
write: 'npm run build && npm run format && node ../.scripts/rewritePackage.js ',
|
|
20
|
+
format: 'npx prettier --write src dist',
|
|
21
|
+
build: 'npm run build:esm && npm run build:cjs && npm run format',
|
|
22
|
+
'build:esm': 'tsc',
|
|
23
|
+
'build:cjs': 'tsc --module CommonJS --outDir dist/cjs',
|
|
30
24
|
},
|
|
31
25
|
repository: {
|
|
32
26
|
type: 'git',
|
|
@@ -37,14 +31,14 @@ exports.default = {
|
|
|
37
31
|
},
|
|
38
32
|
dependencies: {
|
|
39
33
|
'@sapphire/shapeshift': '^3.8.1',
|
|
34
|
+
'dbl-sdk': '^1.2.0',
|
|
40
35
|
'discord.js': '^14.7.1',
|
|
41
|
-
dumfunctions: '^2.1.
|
|
42
|
-
'xernerx-extension-builder': '^0.0.
|
|
36
|
+
dumfunctions: '^2.1.2',
|
|
37
|
+
'xernerx-extension-builder': '^0.0.8',
|
|
43
38
|
zod: '^3.20.6',
|
|
44
39
|
},
|
|
45
40
|
devDependencies: {
|
|
46
41
|
prettier: '^2.8.4',
|
|
47
|
-
tsup: '^6.6.0',
|
|
48
42
|
typescript: '^4.9.5',
|
|
49
43
|
},
|
|
50
44
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.EventEmitterType = exports.ContextCommandType = exports.CommandType = exports.InhibitorType = void 0;
|
|
4
|
-
var InhibitorType;
|
|
1
|
+
export var InhibitorType;
|
|
5
2
|
(function (InhibitorType) {
|
|
6
3
|
InhibitorType['Member'] = 'Member';
|
|
7
4
|
InhibitorType['User'] = 'User';
|
|
@@ -13,8 +10,8 @@ var InhibitorType;
|
|
|
13
10
|
InhibitorType['Message'] = 'Message';
|
|
14
11
|
InhibitorType['Interaction'] = 'Interaction';
|
|
15
12
|
InhibitorType['Channel'] = 'Channel';
|
|
16
|
-
})((InhibitorType =
|
|
17
|
-
var CommandType;
|
|
13
|
+
})((InhibitorType = InhibitorType || (InhibitorType = {})));
|
|
14
|
+
export var CommandType;
|
|
18
15
|
(function (CommandType) {
|
|
19
16
|
CommandType['Message'] = 'MessageCommand';
|
|
20
17
|
CommandType['Slash'] = 'SlashCommand';
|
|
@@ -24,15 +21,15 @@ var CommandType;
|
|
|
24
21
|
CommandType['MessageCommand'] = 'MessageCommand';
|
|
25
22
|
CommandType['SlashCommand'] = 'SlashCommand';
|
|
26
23
|
CommandType['ContextCommand'] = 'ContextCommand';
|
|
27
|
-
})((CommandType =
|
|
28
|
-
var ContextCommandType;
|
|
24
|
+
})((CommandType = CommandType || (CommandType = {})));
|
|
25
|
+
export var ContextCommandType;
|
|
29
26
|
(function (ContextCommandType) {
|
|
30
27
|
ContextCommandType[(ContextCommandType['Message'] = 3)] = 'Message';
|
|
31
28
|
ContextCommandType[(ContextCommandType['User'] = 2)] = 'User';
|
|
32
|
-
})((ContextCommandType =
|
|
33
|
-
var EventEmitterType;
|
|
29
|
+
})((ContextCommandType = ContextCommandType || (ContextCommandType = {})));
|
|
30
|
+
export var EventEmitterType;
|
|
34
31
|
(function (EventEmitterType) {
|
|
35
32
|
EventEmitterType['Client'] = 'client';
|
|
36
33
|
EventEmitterType['Rest'] = 'rest';
|
|
37
34
|
EventEmitterType['Process'] = 'process';
|
|
38
|
-
})((EventEmitterType =
|
|
35
|
+
})((EventEmitterType = EventEmitterType || (EventEmitterType = {})));
|