xernerx 4.0.5 → 4.2.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/SlashCommandBuilder.d.ts +1 -0
- package/dist/build/SlashCommandBuilder.js +1 -0
- package/dist/client/XernerxClient.d.ts +5 -4
- package/dist/client/XernerxClient.js +2 -10
- package/dist/functions/deploy.js +20 -16
- package/dist/handlers/CommandHandler.js +39 -16
- package/dist/handlers/EventHandler.js +1 -1
- package/dist/handlers/ExtensionHandler.js +1 -1
- package/dist/handlers/InhibitorHandler.js +1 -1
- package/dist/main.d.ts +3 -2
- package/dist/main.js +3 -2
- package/dist/tools/XernerxLog.d.ts +1 -0
- package/dist/tools/XernerxLog.js +26 -8
- package/dist/types/extenders.d.ts +11 -6
- package/dist/types/interfaces.d.ts +23 -19
- package/dist/utils/ClientUtil.d.ts +2 -1
- package/dist/utils/ClientUtil.js +10 -1
- package/dist/utils/MessageUtil.d.ts +4 -1
- package/dist/utils/MessageUtil.js +4 -2
- package/package.json +1 -1
- package/dist/build copy/ContextCommandBuilder.d.ts +0 -37
- package/dist/build copy/ContextCommandBuilder.js +0 -88
- package/dist/build copy/EventBuilder.d.ts +0 -21
- package/dist/build copy/EventBuilder.js +0 -34
- package/dist/build copy/InhibitorBuilder.d.ts +0 -19
- package/dist/build copy/InhibitorBuilder.js +0 -27
- package/dist/build copy/MessageCommandBuilder.d.ts +0 -39
- package/dist/build copy/MessageCommandBuilder.js +0 -90
- package/dist/build copy/SlashCommandBuilder.d.ts +0 -41
- package/dist/build copy/SlashCommandBuilder.js +0 -122
- package/dist/client/DBLClient.d.ts +0 -8
- package/dist/client/DBLClient.js +0 -15
- package/dist/client/Top.ggClient.d.ts +0 -1
- package/dist/client/Top.ggClient.js +0 -1
- package/dist/events/messageCreate.d.ts +0 -1
- package/dist/events/messageCreate.js +0 -1
- package/dist/functions/AsyncFunctions.d.ts +0 -1
- package/dist/functions/AsyncFunctions.js +0 -1
- package/dist/functions/getPermissionBitField.d.ts +0 -2
- package/dist/functions/getPermissionBitField.js +0 -17
- package/dist/functions/hasVoted.d.ts +0 -1
- package/dist/functions/hasVoted.js +0 -1
- package/dist/functions/voted.d.ts +0 -1
- package/dist/functions/voted.js +0 -1
- package/dist/models/CommandArguments.d.ts +0 -17
- package/dist/models/CommandArguments.js +0 -101
- package/dist/models/Events.d.ts +0 -24
- package/dist/models/Events.js +0 -297
- package/dist/models/Extensions.d.ts +0 -7
- package/dist/models/Extensions.js +0 -23
- package/dist/models/XernerxUser.d.ts +0 -2
- package/dist/models/XernerxUser.js +0 -9
- package/dist/tools/classes.d.ts +0 -6
- package/dist/tools/classes.js +0 -10
- package/dist/tools/loggers.d.ts +0 -4
- package/dist/tools/loggers.js +0 -4
- package/dist/tools/package.d.ts +0 -42
- package/dist/tools/package.js +0 -41
- package/dist/types/enums.d.ts +0 -44
- package/dist/types/enums.js +0 -35
- package/dist/types/options.d.ts +0 -254
- package/dist/types/options.js +0 -1
- package/dist/utils/CommandUtil.d.ts +0 -58
- package/dist/utils/CommandUtil.js +0 -232
- package/dist/utils/InteractionArguments.d.ts +0 -1
- package/dist/utils/InteractionArguments.js +0 -1
- package/dist/validators/CommandValidations.d.ts +0 -12
- package/dist/validators/CommandValidations.js +0 -166
- package/dist/validators/commands.d.ts +0 -4
- package/dist/validators/commands.js +0 -25
- /package/dist/validators/{InhibitorValidations.d.ts → inhibitorValidations.d.ts} +0 -0
- /package/dist/validators/{InhibitorValidations.js → inhibitorValidations.js} +0 -0
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { Message } from 'discord.js';
|
|
2
|
-
import { CommandType } from '../types/enums.js';
|
|
3
|
-
function getUser(from) {
|
|
4
|
-
if (from instanceof Message) return from.author;
|
|
5
|
-
else return from.user;
|
|
6
|
-
}
|
|
7
|
-
export default function commandValidation(action, command, client, res = false) {
|
|
8
|
-
let user = getUser(action);
|
|
9
|
-
if (client.settings.ignore?.owner && client.util.isOwner(user.id)) return res;
|
|
10
|
-
else if (inCooldown(user, client, command, action)) return true;
|
|
11
|
-
else if (command.owner && !client.util.isOwner(user.id)) {
|
|
12
|
-
res = true;
|
|
13
|
-
emit(client, action, command, 'Not an owner', client.settings.ownerId);
|
|
14
|
-
} else if (command.channelType?.length > 0 || command.channelType) {
|
|
15
|
-
if (!Array.isArray(command.channelType)) command.channelType = [command.channelType];
|
|
16
|
-
if (!command?.channelType?.includes(action.channel?.type)) {
|
|
17
|
-
res = true;
|
|
18
|
-
emit(client, action, command, 'Not the correct channel', command.channelType);
|
|
19
|
-
}
|
|
20
|
-
} else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
|
|
21
|
-
res = true;
|
|
22
|
-
emit(client, action, command, 'Not a whitelisted channel', command.channels);
|
|
23
|
-
} else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
|
|
24
|
-
res = true;
|
|
25
|
-
emit(client, action, command, 'Not a whitelisted guild', command.guilds);
|
|
26
|
-
} else if (command.channelType && command.channelType !== action.channel?.type) {
|
|
27
|
-
res = true;
|
|
28
|
-
emit(client, action, command, 'Not the correct type of channel', command.channelType);
|
|
29
|
-
} else if (action?.guild && (command.permissions?.user || client.settings.permissions?.user)) {
|
|
30
|
-
const permissions = command.permissions?.user || client?.settings?.permissions?.user?.push(...handlerPermissions(client, command.commandType, 'user')),
|
|
31
|
-
missing = [];
|
|
32
|
-
if (Array.isArray(permissions))
|
|
33
|
-
permissions.map((permission) => {
|
|
34
|
-
if (!(action.member?.permissions).has(permission)) {
|
|
35
|
-
missing.push(permission);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
if (missing.length > 0) {
|
|
39
|
-
res = true;
|
|
40
|
-
emit(client, action, command, 'Missing User Permissions', missing);
|
|
41
|
-
}
|
|
42
|
-
} else if (action?.guild && (command.permissions?.client || client.settings.permissions?.client)) {
|
|
43
|
-
const permissions = command.permissions?.client || client?.settings?.permissions?.client?.push(...handlerPermissions(client, command.commandType, 'client')),
|
|
44
|
-
missing = [];
|
|
45
|
-
if (Array.isArray(permissions))
|
|
46
|
-
permissions.map((permission) => {
|
|
47
|
-
if (!(action.member?.permissions).has(permission)) {
|
|
48
|
-
missing.push(permission);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
if (missing.length > 0) {
|
|
52
|
-
res = true;
|
|
53
|
-
emit(client, action, command, 'Missing Client Permissions', missing);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return res;
|
|
57
|
-
}
|
|
58
|
-
function emit(client, action, command, reason, extra) {
|
|
59
|
-
return client.emit('commandBlock', action, command, reason, extra);
|
|
60
|
-
}
|
|
61
|
-
function inCooldown(user, client, command, action) {
|
|
62
|
-
let res = false,
|
|
63
|
-
downs = {};
|
|
64
|
-
const { cooldowns, messageCommands, slashCommands, contextCommands, commands } = client.cache;
|
|
65
|
-
if (command.commandType === CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
|
|
66
|
-
if (messageCommands.has(user.id)) {
|
|
67
|
-
const usr = messageCommands.get(user.id);
|
|
68
|
-
usr.timeRemaining = usr.endsAt - Date.now();
|
|
69
|
-
downs.message = usr;
|
|
70
|
-
res = true;
|
|
71
|
-
}
|
|
72
|
-
if (!messageCommands.has(user.id)) {
|
|
73
|
-
messageCommands.set(user.id, toCooldown(action, command, client.handlerOptions.message.cooldown, user.id));
|
|
74
|
-
setInterval(() => {
|
|
75
|
-
messageCommands.delete(user.id);
|
|
76
|
-
}, client.handlerOptions.message.cooldown);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (command.commandType === CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
|
|
80
|
-
if (slashCommands.has(user.id)) {
|
|
81
|
-
const usr = slashCommands.get(user.id);
|
|
82
|
-
usr.timeRemaining = usr.endsAt - Date.now();
|
|
83
|
-
downs.slash = usr;
|
|
84
|
-
res = true;
|
|
85
|
-
}
|
|
86
|
-
if (!slashCommands.has(user.id)) {
|
|
87
|
-
slashCommands.set(user.id, toCooldown(action, command, client.handlerOptions.slash.cooldown, user.id));
|
|
88
|
-
setInterval(() => {
|
|
89
|
-
slashCommands.delete(user.id);
|
|
90
|
-
}, client.handlerOptions.slash.cooldown);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (command.commandType === CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
|
|
94
|
-
if (contextCommands.has(user.id)) {
|
|
95
|
-
const usr = contextCommands.get(user.id);
|
|
96
|
-
usr.timeRemaining = usr.endsAt - Date.now();
|
|
97
|
-
downs.context = usr;
|
|
98
|
-
res = true;
|
|
99
|
-
}
|
|
100
|
-
if (!contextCommands.has(user.id)) {
|
|
101
|
-
contextCommands.set(user.id, toCooldown(action, command, client.handlerOptions.context.cooldown, user.id));
|
|
102
|
-
setInterval(() => {
|
|
103
|
-
contextCommands.delete(user.id);
|
|
104
|
-
}, client.handlerOptions.context.cooldown);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (client.settings?.cooldown?.default) {
|
|
108
|
-
if (cooldowns.has(user.id)) {
|
|
109
|
-
const usr = cooldowns.get(user.id);
|
|
110
|
-
usr.timeRemaining = usr.endsAt - Date.now();
|
|
111
|
-
downs.default = usr;
|
|
112
|
-
res = true;
|
|
113
|
-
}
|
|
114
|
-
if (!cooldowns.has(user.id)) {
|
|
115
|
-
cooldowns.set(user.id, toCooldown(action, command, client.settings.cooldown.default, user.id));
|
|
116
|
-
setInterval(() => {
|
|
117
|
-
cooldowns.delete(user.id);
|
|
118
|
-
}, client.settings.cooldown.default);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (command.cooldown) {
|
|
122
|
-
const name = user.id + '-' + (command.data?.name || command?.name) + '-' + command.commandType;
|
|
123
|
-
if (commands.has(name)) {
|
|
124
|
-
const usr = commands.get(name);
|
|
125
|
-
usr.timeRemaining = usr.endsAt - Date.now();
|
|
126
|
-
downs.command = usr;
|
|
127
|
-
res = true;
|
|
128
|
-
}
|
|
129
|
-
if (!commands.has(name)) {
|
|
130
|
-
commands.set(name, toCooldown(action, command, command.cooldown, name));
|
|
131
|
-
setInterval(() => {
|
|
132
|
-
commands.delete(name);
|
|
133
|
-
}, command.cooldown);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (Object.keys(downs).length > 0) client.emit('commandCooldown', action, command, downs);
|
|
137
|
-
return res;
|
|
138
|
-
}
|
|
139
|
-
function toCooldown(action, command, cooldown, name) {
|
|
140
|
-
let user = getUser(action);
|
|
141
|
-
return {
|
|
142
|
-
name,
|
|
143
|
-
id: user.id,
|
|
144
|
-
tag: user.tag,
|
|
145
|
-
commandType: command.commandType,
|
|
146
|
-
commandName: command?.data?.name || command?.name,
|
|
147
|
-
guildId: action?.guild?.id,
|
|
148
|
-
channelId: action?.channel?.id,
|
|
149
|
-
startsAt: Number(Date.now()),
|
|
150
|
-
endsAt: Number(Date.now()) + cooldown,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
function handlerPermissions(client, commandType, type) {
|
|
154
|
-
let permissions = [];
|
|
155
|
-
if (commandType === CommandType.MessageCommand) {
|
|
156
|
-
if (type === 'user') permissions = client.handlerOptions.message?.userPermissions || [];
|
|
157
|
-
else if (type === 'client') permissions = client.handlerOptions.message?.clientPermissions || [];
|
|
158
|
-
} else if (commandType === CommandType.SlashCommand) {
|
|
159
|
-
if (type === 'user') permissions = client.handlerOptions.slash?.userPermissions || [];
|
|
160
|
-
else if (type === 'client') permissions = client.handlerOptions.slash?.clientPermissions || [];
|
|
161
|
-
} else if (commandType === CommandType.ContextCommand) {
|
|
162
|
-
if (type === 'user') permissions = client.handlerOptions.context?.userPermissions || [];
|
|
163
|
-
else if (type === 'client') permissions = client.handlerOptions.context?.clientPermissions || [];
|
|
164
|
-
}
|
|
165
|
-
return permissions;
|
|
166
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ContextCommandBuilder, MessageCommandBuilder, SlashCommandBuilder } from '../main.js';
|
|
2
|
-
import { XernerxMessage } from '../types/extenders.js';
|
|
3
|
-
import { XernerxInteraction } from '../types/types.js';
|
|
4
|
-
export default function commandValidation(event: XernerxInteraction | XernerxMessage, command: MessageCommandBuilder | SlashCommandBuilder | ContextCommandBuilder): Promise<boolean>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ChannelType, PermissionFlagsBits } from '../main.js';
|
|
2
|
-
export default async function commandValidation(event, command) {
|
|
3
|
-
if (command.permissions?.dm == false && event.channel?.type === ChannelType.DM) return await emit(event, "Can't use in a DM Channel");
|
|
4
|
-
if (command.permissions?.user) {
|
|
5
|
-
if (!(event.member?.permissions).has(toBigInt(command.permissions.user))) return await emit(event, 'Missing User Permissions');
|
|
6
|
-
}
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
async function emit(event, reason) {
|
|
10
|
-
return await event.client.emit('commandBlock', event, reason);
|
|
11
|
-
}
|
|
12
|
-
function toBigInt(permissions) {
|
|
13
|
-
let bigIntPermissions = 0n;
|
|
14
|
-
permissions.map((permission) => {
|
|
15
|
-
permission =
|
|
16
|
-
PermissionFlagsBits[
|
|
17
|
-
permission
|
|
18
|
-
.split(/ +/)
|
|
19
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
20
|
-
.join('')
|
|
21
|
-
];
|
|
22
|
-
if (typeof permission === 'bigint') bigIntPermissions += permission;
|
|
23
|
-
});
|
|
24
|
-
return bigIntPermissions;
|
|
25
|
-
}
|
|
File without changes
|
|
File without changes
|