xernerx 3.4.3 → 3.5.1
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/README.md +10 -10
- package/dist/build/ContextCommandBuilder.d.ts +60 -42
- package/dist/build/ContextCommandBuilder.js +93 -86
- package/dist/build/EventBuilder.d.ts +21 -17
- package/dist/build/EventBuilder.js +34 -35
- package/dist/build/InhibitorBuilder.d.ts +19 -20
- package/dist/build/InhibitorBuilder.js +27 -27
- package/dist/build/MessageCommandBuilder.d.ts +53 -42
- package/dist/build/MessageCommandBuilder.js +90 -78
- package/dist/build/SlashCommandBuilder.d.ts +58 -40
- package/dist/build/SlashCommandBuilder.js +125 -118
- package/dist/client/XernerxClient.d.ts +28 -28
- package/dist/client/XernerxClient.js +101 -83
- package/dist/handlers/CommandHandler.d.ts +27 -27
- package/dist/handlers/CommandHandler.js +42 -42
- package/dist/handlers/EventHandler.d.ts +13 -13
- package/dist/handlers/EventHandler.js +16 -16
- package/dist/handlers/Handler.d.ts +57 -57
- package/dist/handlers/Handler.js +250 -250
- package/dist/handlers/InhibitorHandler.d.ts +18 -18
- package/dist/handlers/InhibitorHandler.js +21 -21
- package/dist/main.cjs +2023 -0
- package/dist/main.d.ts +30 -30
- package/dist/main.js +42 -42
- package/dist/models/CommandArguments.d.ts +17 -17
- package/dist/models/CommandArguments.js +121 -123
- package/dist/models/Events.d.ts +24 -24
- package/dist/models/Events.js +294 -304
- package/dist/models/Extensions.d.ts +7 -7
- package/dist/models/Extensions.js +23 -23
- package/dist/tools/XernerxError.d.ts +5 -5
- package/dist/tools/XernerxError.js +8 -8
- package/dist/tools/package.d.ts +49 -38
- package/dist/tools/package.js +48 -41
- package/dist/types/enums.d.ts +35 -35
- package/dist/types/enums.js +35 -35
- package/dist/types/interfaces.d.ts +25 -25
- package/dist/types/interfaces.js +1 -1
- package/dist/types/options.d.ts +241 -206
- package/dist/types/options.js +1 -1
- package/dist/types/types.d.ts +34 -32
- package/dist/types/types.js +1 -1
- package/dist/utils/ClientUtil.d.ts +25 -25
- package/dist/utils/ClientUtil.js +222 -218
- package/dist/utils/CommandUtil.d.ts +56 -56
- package/dist/utils/CommandUtil.js +248 -260
- package/dist/validators/CommandValidations.d.ts +7 -7
- package/dist/validators/CommandValidations.js +183 -185
- package/dist/validators/InhibitorValidations.d.ts +11 -11
- package/dist/validators/InhibitorValidations.js +42 -42
- package/dist/validators/Shapes.js +1 -0
- package/package.json +54 -39
- package/dist/build/XContextCommandBuilder.d.ts +0 -40
- package/dist/build/XContextCommandBuilder.js +0 -84
- package/dist/build/XEventBuilder.d.ts +0 -17
- package/dist/build/XEventBuilder.js +0 -35
- package/dist/build/XInhibitorBuilder.d.ts +0 -20
- package/dist/build/XInhibitorBuilder.js +0 -28
- package/dist/build/XMessageCommandBuilder.d.ts +0 -42
- package/dist/build/XMessageCommandBuilder.js +0 -80
- package/dist/build/XSlashCommandBuilder.d.ts +0 -36
- package/dist/build/XSlashCommandBuilder.js +0 -114
- package/dist/models/CommandValidations.d.ts +0 -4
- package/dist/models/CommandValidations.js +0 -183
- package/dist/models/InhibitorValidations.d.ts +0 -12
- package/dist/models/InhibitorValidations.js +0 -42
|
@@ -1,185 +1,183 @@
|
|
|
1
|
-
import { Message } from 'discord.js';
|
|
2
|
-
import { CommandType } from '../types/enums.js';
|
|
3
|
-
function getUser(from) {
|
|
4
|
-
if (from instanceof Message)
|
|
5
|
-
return from.author;
|
|
6
|
-
else
|
|
7
|
-
return from.user;
|
|
8
|
-
}
|
|
9
|
-
export default function commandValidation(action, command, client, res = false) {
|
|
10
|
-
let user = getUser(action);
|
|
11
|
-
if ((command.ignoreOwner || client.settings.
|
|
12
|
-
return res;
|
|
13
|
-
else if (inCooldown(user, client, command, action))
|
|
14
|
-
return true;
|
|
15
|
-
else if (command.owner && !client.util.isOwner(user.id)) {
|
|
16
|
-
res = true;
|
|
17
|
-
emit(client, action, command, 'Not an owner', client.settings.ownerId);
|
|
18
|
-
}
|
|
19
|
-
else if (command.channelType?.length > 0 || command.channelType) {
|
|
20
|
-
if (!Array.isArray(command.channelType))
|
|
21
|
-
command.channelType = [command.channelType];
|
|
22
|
-
if (!command?.channelType?.includes(action.channel?.type)) {
|
|
23
|
-
res = true;
|
|
24
|
-
emit(client, action, command, 'Not the correct channel', command.channelType);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
|
|
28
|
-
res = true;
|
|
29
|
-
emit(client, action, command, 'Not a whitelisted channel', command.channels);
|
|
30
|
-
}
|
|
31
|
-
else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
|
|
32
|
-
res = true;
|
|
33
|
-
emit(client, action, command, 'Not a whitelisted guild', command.guilds);
|
|
34
|
-
}
|
|
35
|
-
else if (command.channelType && command.channelType !== action.channel?.type) {
|
|
36
|
-
res = true;
|
|
37
|
-
emit(client, action, command, 'Not the correct type of channel', command.channelType);
|
|
38
|
-
}
|
|
39
|
-
else if (action?.guild && (command.
|
|
40
|
-
const permissions = command.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (type === '
|
|
168
|
-
permissions = client.handlerOptions.message?.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (type === '
|
|
174
|
-
permissions = client.handlerOptions.slash?.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (type === '
|
|
180
|
-
permissions = client.handlerOptions.context?.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return permissions;
|
|
185
|
-
}
|
|
1
|
+
import { Message } from 'discord.js';
|
|
2
|
+
import { CommandType } from '../types/enums.js';
|
|
3
|
+
function getUser(from) {
|
|
4
|
+
if (from instanceof Message)
|
|
5
|
+
return from.author;
|
|
6
|
+
else
|
|
7
|
+
return from.user;
|
|
8
|
+
}
|
|
9
|
+
export default function commandValidation(action, command, client, res = false) {
|
|
10
|
+
let user = getUser(action);
|
|
11
|
+
if ((command.ignoreOwner || client.settings.ignore?.owner) && client.util.isOwner(user.id))
|
|
12
|
+
return res;
|
|
13
|
+
else if (inCooldown(user, client, command, action))
|
|
14
|
+
return true;
|
|
15
|
+
else if (command.owner && !client.util.isOwner(user.id)) {
|
|
16
|
+
res = true;
|
|
17
|
+
emit(client, action, command, 'Not an owner', client.settings.ownerId);
|
|
18
|
+
}
|
|
19
|
+
else if (command.channelType?.length > 0 || command.channelType) {
|
|
20
|
+
if (!Array.isArray(command.channelType))
|
|
21
|
+
command.channelType = [command.channelType];
|
|
22
|
+
if (!command?.channelType?.includes(action.channel?.type)) {
|
|
23
|
+
res = true;
|
|
24
|
+
emit(client, action, command, 'Not the correct channel', command.channelType);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
|
|
28
|
+
res = true;
|
|
29
|
+
emit(client, action, command, 'Not a whitelisted channel', command.channels);
|
|
30
|
+
}
|
|
31
|
+
else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
|
|
32
|
+
res = true;
|
|
33
|
+
emit(client, action, command, 'Not a whitelisted guild', command.guilds);
|
|
34
|
+
}
|
|
35
|
+
else if (command.channelType && command.channelType !== action.channel?.type) {
|
|
36
|
+
res = true;
|
|
37
|
+
emit(client, action, command, 'Not the correct type of channel', command.channelType);
|
|
38
|
+
}
|
|
39
|
+
else if (action?.guild && (command.permissions?.user || client.settings.permissions?.user)) {
|
|
40
|
+
const permissions = command.permissions?.user || client?.settings?.permissions?.user?.push(...handlerPermissions(client, command.commandType, 'user')), missing = [];
|
|
41
|
+
if (Array.isArray(permissions))
|
|
42
|
+
permissions.map((permission) => {
|
|
43
|
+
if (!(action.member?.permissions).has(permission)) {
|
|
44
|
+
missing.push(permission);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (missing.length > 0) {
|
|
48
|
+
res = true;
|
|
49
|
+
emit(client, action, command, 'Missing User Permissions', missing);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (action?.guild && (command.permissions?.client || client.settings.permissions?.client)) {
|
|
53
|
+
const permissions = command.permissions?.client || client?.settings?.permissions?.client?.push(...handlerPermissions(client, command.commandType, 'client')), missing = [];
|
|
54
|
+
if (Array.isArray(permissions))
|
|
55
|
+
permissions.map((permission) => {
|
|
56
|
+
if (!(action.member?.permissions).has(permission)) {
|
|
57
|
+
missing.push(permission);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (missing.length > 0) {
|
|
61
|
+
res = true;
|
|
62
|
+
emit(client, action, command, 'Missing Client Permissions', missing);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return res;
|
|
66
|
+
}
|
|
67
|
+
function emit(client, action, command, reason, extra) {
|
|
68
|
+
return client.emit('commandBlock', action, command, reason, extra);
|
|
69
|
+
}
|
|
70
|
+
function inCooldown(user, client, command, action) {
|
|
71
|
+
let res = false, downs = {};
|
|
72
|
+
const { cooldowns, messageCommands, slashCommands, contextCommands, commands } = client.cache;
|
|
73
|
+
if (command.commandType === CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
|
|
74
|
+
if (messageCommands.has(user.id)) {
|
|
75
|
+
const usr = messageCommands.get(user.id);
|
|
76
|
+
usr.timeRemaining = usr.endsAt - Date.now();
|
|
77
|
+
downs.message = usr;
|
|
78
|
+
res = true;
|
|
79
|
+
}
|
|
80
|
+
if (!messageCommands.has(user.id)) {
|
|
81
|
+
messageCommands.set(user.id, toCooldown(action, command, client.handlerOptions.message.cooldown, user.id));
|
|
82
|
+
setInterval(() => {
|
|
83
|
+
messageCommands.delete(user.id);
|
|
84
|
+
}, client.handlerOptions.message.cooldown);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (command.commandType === CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
|
|
88
|
+
if (slashCommands.has(user.id)) {
|
|
89
|
+
const usr = slashCommands.get(user.id);
|
|
90
|
+
usr.timeRemaining = usr.endsAt - Date.now();
|
|
91
|
+
downs.slash = usr;
|
|
92
|
+
res = true;
|
|
93
|
+
}
|
|
94
|
+
if (!slashCommands.has(user.id)) {
|
|
95
|
+
slashCommands.set(user.id, toCooldown(action, command, client.handlerOptions.slash.cooldown, user.id));
|
|
96
|
+
setInterval(() => {
|
|
97
|
+
slashCommands.delete(user.id);
|
|
98
|
+
}, client.handlerOptions.slash.cooldown);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (command.commandType === CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
|
|
102
|
+
if (contextCommands.has(user.id)) {
|
|
103
|
+
const usr = contextCommands.get(user.id);
|
|
104
|
+
usr.timeRemaining = usr.endsAt - Date.now();
|
|
105
|
+
downs.context = usr;
|
|
106
|
+
res = true;
|
|
107
|
+
}
|
|
108
|
+
if (!contextCommands.has(user.id)) {
|
|
109
|
+
contextCommands.set(user.id, toCooldown(action, command, client.handlerOptions.context.cooldown, user.id));
|
|
110
|
+
setInterval(() => {
|
|
111
|
+
contextCommands.delete(user.id);
|
|
112
|
+
}, client.handlerOptions.context.cooldown);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (client.settings?.cooldown?.default) {
|
|
116
|
+
if (cooldowns.has(user.id)) {
|
|
117
|
+
const usr = cooldowns.get(user.id);
|
|
118
|
+
usr.timeRemaining = usr.endsAt - Date.now();
|
|
119
|
+
downs.default = usr;
|
|
120
|
+
res = true;
|
|
121
|
+
}
|
|
122
|
+
if (!cooldowns.has(user.id)) {
|
|
123
|
+
cooldowns.set(user.id, toCooldown(action, command, client.settings.cooldown.default, user.id));
|
|
124
|
+
setInterval(() => {
|
|
125
|
+
cooldowns.delete(user.id);
|
|
126
|
+
}, client.settings.cooldown.default);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (command.cooldown) {
|
|
130
|
+
const name = user.id + '-' + (command.data?.name || command?.name) + '-' + command.commandType;
|
|
131
|
+
if (commands.has(name)) {
|
|
132
|
+
const usr = commands.get(name);
|
|
133
|
+
usr.timeRemaining = usr.endsAt - Date.now();
|
|
134
|
+
downs.command = usr;
|
|
135
|
+
res = true;
|
|
136
|
+
}
|
|
137
|
+
if (!commands.has(name)) {
|
|
138
|
+
commands.set(name, toCooldown(action, command, command.cooldown, name));
|
|
139
|
+
setInterval(() => {
|
|
140
|
+
commands.delete(name);
|
|
141
|
+
}, command.cooldown);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (Object.keys(downs).length > 0)
|
|
145
|
+
client.emit('commandCooldown', action, command, downs);
|
|
146
|
+
return res;
|
|
147
|
+
}
|
|
148
|
+
function toCooldown(action, command, cooldown, name) {
|
|
149
|
+
let user = getUser(action);
|
|
150
|
+
return {
|
|
151
|
+
name,
|
|
152
|
+
id: user.id,
|
|
153
|
+
tag: user.tag,
|
|
154
|
+
commandType: command.commandType,
|
|
155
|
+
commandName: command?.data?.name || command?.name,
|
|
156
|
+
guildId: action?.guild?.id,
|
|
157
|
+
channelId: action?.channel?.id,
|
|
158
|
+
startsAt: Number(Date.now()),
|
|
159
|
+
endsAt: Number(Date.now()) + cooldown,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function handlerPermissions(client, commandType, type) {
|
|
163
|
+
let permissions = [];
|
|
164
|
+
if (commandType === CommandType.MessageCommand) {
|
|
165
|
+
if (type === 'user')
|
|
166
|
+
permissions = client.handlerOptions.message?.userPermissions || [];
|
|
167
|
+
else if (type === 'client')
|
|
168
|
+
permissions = client.handlerOptions.message?.clientPermissions || [];
|
|
169
|
+
}
|
|
170
|
+
else if (commandType === CommandType.SlashCommand) {
|
|
171
|
+
if (type === 'user')
|
|
172
|
+
permissions = client.handlerOptions.slash?.userPermissions || [];
|
|
173
|
+
else if (type === 'client')
|
|
174
|
+
permissions = client.handlerOptions.slash?.clientPermissions || [];
|
|
175
|
+
}
|
|
176
|
+
else if (commandType === CommandType.ContextCommand) {
|
|
177
|
+
if (type === 'user')
|
|
178
|
+
permissions = client.handlerOptions.context?.userPermissions || [];
|
|
179
|
+
else if (type === 'client')
|
|
180
|
+
permissions = client.handlerOptions.context?.clientPermissions || [];
|
|
181
|
+
}
|
|
182
|
+
return permissions;
|
|
183
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
2
|
-
import { XernerxInteraction, XernerxMessage } from '../types/types.js';
|
|
3
|
-
export declare class InhibitorValidation {
|
|
4
|
-
client: XernerxClient;
|
|
5
|
-
action: XernerxMessage | XernerxInteraction;
|
|
6
|
-
command: string;
|
|
7
|
-
inhibited: Record<string, string | void>;
|
|
8
|
-
constructor(client: XernerxClient, action: XernerxMessage | XernerxInteraction, command: string);
|
|
9
|
-
inhibit(): Promise<Record<string, string | void> | undefined>;
|
|
10
|
-
private args;
|
|
11
|
-
}
|
|
1
|
+
import XernerxClient from '../client/XernerxClient.js';
|
|
2
|
+
import { XernerxInteraction, XernerxMessage } from '../types/types.js';
|
|
3
|
+
export declare class InhibitorValidation {
|
|
4
|
+
client: XernerxClient;
|
|
5
|
+
action: XernerxMessage | XernerxInteraction;
|
|
6
|
+
command: string;
|
|
7
|
+
inhibited: Record<string, string | void>;
|
|
8
|
+
constructor(client: XernerxClient, action: XernerxMessage | XernerxInteraction, command: string);
|
|
9
|
+
inhibit(): Promise<Record<string, string | void> | undefined>;
|
|
10
|
+
private args;
|
|
11
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { InhibitorType } from '../types/enums.js';
|
|
2
|
-
export class InhibitorValidation {
|
|
3
|
-
client;
|
|
4
|
-
action;
|
|
5
|
-
command;
|
|
6
|
-
inhibited;
|
|
7
|
-
constructor(client, action, command) {
|
|
8
|
-
this.client = client;
|
|
9
|
-
this.action = action;
|
|
10
|
-
this.command = command;
|
|
11
|
-
this.inhibited = {};
|
|
12
|
-
}
|
|
13
|
-
async inhibit() {
|
|
14
|
-
for (const inhibitor of this.client.inhibitors) {
|
|
15
|
-
const inhibit = inhibitor[1];
|
|
16
|
-
if (inhibit)
|
|
17
|
-
this.inhibited[inhibit.name] = await inhibit.check(this.action, this.args(this.action, inhibit.type));
|
|
18
|
-
}
|
|
19
|
-
for (const inhibit of Object.values(this.inhibited)) {
|
|
20
|
-
if (inhibit)
|
|
21
|
-
return this.inhibited;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
args(action, type) {
|
|
25
|
-
if (type === InhibitorType.Channel)
|
|
26
|
-
return action.channel;
|
|
27
|
-
if (type === InhibitorType.User)
|
|
28
|
-
return action.author || action.user;
|
|
29
|
-
if (type === InhibitorType.Guild)
|
|
30
|
-
return action.guild;
|
|
31
|
-
if (type === InhibitorType.Member)
|
|
32
|
-
return action.member;
|
|
33
|
-
// if (type === InhibitorType.Command)
|
|
34
|
-
// return this.client.util.getAllCommands().filter(this.command.name);
|
|
35
|
-
// if (type === InhibitorType.MessageCommand)
|
|
36
|
-
// return this.client.util.getAllMessageCommands().find(this.command.name);
|
|
37
|
-
// if (type === InhibitorType.SlashCommand)
|
|
38
|
-
// return this.client.util.getAllSlashCommands().find(this.command.name);
|
|
39
|
-
// if (type === InhibitorType.ContextCommand)
|
|
40
|
-
// return this.client.util.getAllContextCommands().find(this.command.name);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
import { InhibitorType } from '../types/enums.js';
|
|
2
|
+
export class InhibitorValidation {
|
|
3
|
+
client;
|
|
4
|
+
action;
|
|
5
|
+
command;
|
|
6
|
+
inhibited;
|
|
7
|
+
constructor(client, action, command) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.action = action;
|
|
10
|
+
this.command = command;
|
|
11
|
+
this.inhibited = {};
|
|
12
|
+
}
|
|
13
|
+
async inhibit() {
|
|
14
|
+
for (const inhibitor of this.client.inhibitors) {
|
|
15
|
+
const inhibit = inhibitor[1];
|
|
16
|
+
if (inhibit)
|
|
17
|
+
this.inhibited[inhibit.name] = await inhibit.check(this.action, this.args(this.action, inhibit.type));
|
|
18
|
+
}
|
|
19
|
+
for (const inhibit of Object.values(this.inhibited)) {
|
|
20
|
+
if (inhibit)
|
|
21
|
+
return this.inhibited;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
args(action, type) {
|
|
25
|
+
if (type === InhibitorType.Channel)
|
|
26
|
+
return action.channel;
|
|
27
|
+
if (type === InhibitorType.User)
|
|
28
|
+
return action.author || action.user;
|
|
29
|
+
if (type === InhibitorType.Guild)
|
|
30
|
+
return action.guild;
|
|
31
|
+
if (type === InhibitorType.Member)
|
|
32
|
+
return action.member;
|
|
33
|
+
// if (type === InhibitorType.Command)
|
|
34
|
+
// return this.client.util.getAllCommands().filter(this.command.name);
|
|
35
|
+
// if (type === InhibitorType.MessageCommand)
|
|
36
|
+
// return this.client.util.getAllMessageCommands().find(this.command.name);
|
|
37
|
+
// if (type === InhibitorType.SlashCommand)
|
|
38
|
+
// return this.client.util.getAllSlashCommands().find(this.command.name);
|
|
39
|
+
// if (type === InhibitorType.ContextCommand)
|
|
40
|
+
// return this.client.util.getAllContextCommands().find(this.command.name);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,41 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
2
|
+
"name": "xernerx",
|
|
3
|
+
"version": "3.5.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A bot framework for discord.js.",
|
|
6
|
+
"main": "dist/main.js",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"discord.js",
|
|
9
|
+
"discord",
|
|
10
|
+
"framework",
|
|
11
|
+
"mjs",
|
|
12
|
+
"esm",
|
|
13
|
+
"cjs",
|
|
14
|
+
"ts"
|
|
15
|
+
],
|
|
16
|
+
"author": "Dummi",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"homepage": "https://xernerx.github.io/xernerx/home.html",
|
|
19
|
+
"packageManager": "npm@8.5.5",
|
|
20
|
+
"exports": {
|
|
21
|
+
"import": "./dist/main.js",
|
|
22
|
+
"require": "./dist/main.cjs",
|
|
23
|
+
"types": "./types",
|
|
24
|
+
"node": null,
|
|
25
|
+
"default": null
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"start": "npm i && npm fund && npm audit fix --force && npm link && tsc -w",
|
|
29
|
+
"patch": "npm run write && git add . && npm run commit && npm version patch && npm publish && git push",
|
|
30
|
+
"minor": "npm run write && git add . && npm run commit && npm version minor && npm publish && git push",
|
|
31
|
+
"major": "npm run write && git add . && npm run commit && npm version major && npm publish && git push",
|
|
32
|
+
"site": "git add docs && npm run commit && git push",
|
|
33
|
+
"commit": "node ../.scripts/commit.js",
|
|
34
|
+
"write": "npm run build && node ../.scripts/rewritePackage.js ",
|
|
35
|
+
"build": "tsc && npx tsup src/main.ts && npx prettier --write src"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/xernerx/xernerx.git"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/xernerx/xernerx/issues"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@sapphire/shapeshift": "^3.8.1",
|
|
46
|
+
"discord.js": "^14.7.1",
|
|
47
|
+
"dumfunctions": "^2.1.1",
|
|
48
|
+
"xernerx-extension-builder": "^0.0.5",
|
|
49
|
+
"zod": "^3.20.6"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"prettier": "^2.8.4",
|
|
53
|
+
"tsup": "^6.6.0",
|
|
54
|
+
"typescript": "^4.9.5"
|
|
55
|
+
}
|
|
41
56
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ChannelType, ContextMenuCommandBuilder, Interaction } from 'discord.js';
|
|
2
|
-
import { ContextCommandOptions } from '../types/options.js';
|
|
3
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
4
|
-
/**
|
|
5
|
-
* @description The command builder for context commands.
|
|
6
|
-
* @param {String} id - The unique ID of the command.
|
|
7
|
-
* @param {ContextCommandOptions} options - The command options.
|
|
8
|
-
*/
|
|
9
|
-
export default class XContextCommandBuilder {
|
|
10
|
-
id: string;
|
|
11
|
-
data: ContextMenuCommandBuilder;
|
|
12
|
-
description?: string;
|
|
13
|
-
info?: string;
|
|
14
|
-
category?: string;
|
|
15
|
-
owner?: boolean;
|
|
16
|
-
channelType?: ChannelType | ChannelType[];
|
|
17
|
-
cooldown?: number;
|
|
18
|
-
ignoreOwner?: boolean;
|
|
19
|
-
channels?: string[];
|
|
20
|
-
guilds?: string[];
|
|
21
|
-
userPermissions?: bigint[];
|
|
22
|
-
clientPermissions?: bigint[];
|
|
23
|
-
defer?: {
|
|
24
|
-
reply?: boolean;
|
|
25
|
-
ephemeral?: boolean;
|
|
26
|
-
fetchReply?: boolean;
|
|
27
|
-
};
|
|
28
|
-
client: XernerxClient | object;
|
|
29
|
-
constructor(id: string, options: ContextCommandOptions);
|
|
30
|
-
/**
|
|
31
|
-
* @param {Interaction} interaction - The Discord interaction event data.
|
|
32
|
-
* @description make any preconditions here.
|
|
33
|
-
*/
|
|
34
|
-
conditions(interaction: Interaction): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* @param {Interaction} interaction - The Discord interaction event data.
|
|
37
|
-
* @description Make your custom command here.
|
|
38
|
-
*/
|
|
39
|
-
exec(interaction: Interaction): Promise<void>;
|
|
40
|
-
}
|