xernerx 3.6.0 → 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/{cjs/models → models}/CommandArguments.js +2 -7
- package/dist/{mjs/models → models}/Events.js +44 -56
- package/dist/models/Extensions.js +23 -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/{mjs/tools → tools}/package.d.ts +1 -0
- package/dist/{cjs/tools → tools}/package.js +4 -5
- 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/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 +10 -13
- 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 -14
- package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -63
- 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 -29
- package/dist/cjs/client/XernerxClient.js +0 -120
- 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/handlers/WebhookHandler.d.ts +0 -7
- package/dist/cjs/handlers/WebhookHandler.js +0 -23
- package/dist/cjs/main.d.ts +0 -44
- package/dist/cjs/main.js +0 -112
- package/dist/cjs/models/Events.js +0 -309
- package/dist/cjs/models/Extensions.js +0 -26
- package/dist/cjs/models/XernerxUser.js +0 -12
- package/dist/cjs/tools/XernerxError.d.ts +0 -5
- package/dist/cjs/tools/XernerxError.js +0 -11
- package/dist/cjs/tools/package.d.ts +0 -44
- package/dist/cjs/types/interfaces.d.ts +0 -27
- package/dist/cjs/types/interfaces.js +0 -2
- package/dist/cjs/types/options.js +0 -2
- package/dist/cjs/types/types.d.ts +0 -62
- package/dist/cjs/types/types.js +0 -2
- package/dist/cjs/utils/ClientUtil.d.ts +0 -26
- 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 -63
- 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 -29
- package/dist/mjs/client/XernerxClient.js +0 -120
- 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/handlers/WebhookHandler.d.ts +0 -7
- package/dist/mjs/handlers/WebhookHandler.js +0 -23
- 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/CommandArguments.js +0 -106
- 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/models/XernerxUser.d.ts +0 -2
- package/dist/mjs/models/XernerxUser.js +0 -12
- package/dist/mjs/tools/XernerxError.d.ts +0 -5
- package/dist/mjs/tools/XernerxError.js +0 -11
- package/dist/mjs/tools/package.js +0 -45
- 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 -27
- package/dist/mjs/types/interfaces.js +0 -2
- package/dist/mjs/types/options.d.ts +0 -254
- package/dist/mjs/types/options.js +0 -2
- package/dist/mjs/types/types.d.ts +0 -62
- package/dist/mjs/types/types.js +0 -2
- package/dist/mjs/utils/ClientUtil.d.ts +0 -26
- 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/models → models}/XernerxUser.d.ts +0 -0
- /package/dist/{cjs/types → types}/enums.d.ts +0 -0
- /package/dist/{cjs/types → types}/options.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/CommandUtil.d.ts +0 -0
- /package/dist/{cjs/validators → validators}/CommandValidations.d.ts +0 -0
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const discord_js_1 = require('discord.js');
|
|
4
|
-
const enums_js_1 = require('../types/enums.js');
|
|
1
|
+
import { Message } from 'discord.js';
|
|
2
|
+
import { CommandType } from '../types/enums.js';
|
|
5
3
|
function getUser(from) {
|
|
6
|
-
if (from instanceof
|
|
4
|
+
if (from instanceof Message) return from.author;
|
|
7
5
|
else return from.user;
|
|
8
6
|
}
|
|
9
|
-
function commandValidation(action, command, client, res = false) {
|
|
7
|
+
export default function commandValidation(action, command, client, res = false) {
|
|
10
8
|
let user = getUser(action);
|
|
11
9
|
if (client.settings.ignore?.owner && client.util.isOwner(user.id)) return res;
|
|
12
10
|
else if (inCooldown(user, client, command, action)) return true;
|
|
@@ -57,7 +55,6 @@ function commandValidation(action, command, client, res = false) {
|
|
|
57
55
|
}
|
|
58
56
|
return res;
|
|
59
57
|
}
|
|
60
|
-
exports.default = commandValidation;
|
|
61
58
|
function emit(client, action, command, reason, extra) {
|
|
62
59
|
return client.emit('commandBlock', action, command, reason, extra);
|
|
63
60
|
}
|
|
@@ -65,7 +62,7 @@ function inCooldown(user, client, command, action) {
|
|
|
65
62
|
let res = false,
|
|
66
63
|
downs = {};
|
|
67
64
|
const { cooldowns, messageCommands, slashCommands, contextCommands, commands } = client.cache;
|
|
68
|
-
if (command.commandType ===
|
|
65
|
+
if (command.commandType === CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
|
|
69
66
|
if (messageCommands.has(user.id)) {
|
|
70
67
|
const usr = messageCommands.get(user.id);
|
|
71
68
|
usr.timeRemaining = usr.endsAt - Date.now();
|
|
@@ -79,7 +76,7 @@ function inCooldown(user, client, command, action) {
|
|
|
79
76
|
}, client.handlerOptions.message.cooldown);
|
|
80
77
|
}
|
|
81
78
|
}
|
|
82
|
-
if (command.commandType ===
|
|
79
|
+
if (command.commandType === CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
|
|
83
80
|
if (slashCommands.has(user.id)) {
|
|
84
81
|
const usr = slashCommands.get(user.id);
|
|
85
82
|
usr.timeRemaining = usr.endsAt - Date.now();
|
|
@@ -93,7 +90,7 @@ function inCooldown(user, client, command, action) {
|
|
|
93
90
|
}, client.handlerOptions.slash.cooldown);
|
|
94
91
|
}
|
|
95
92
|
}
|
|
96
|
-
if (command.commandType ===
|
|
93
|
+
if (command.commandType === CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
|
|
97
94
|
if (contextCommands.has(user.id)) {
|
|
98
95
|
const usr = contextCommands.get(user.id);
|
|
99
96
|
usr.timeRemaining = usr.endsAt - Date.now();
|
|
@@ -155,13 +152,13 @@ function toCooldown(action, command, cooldown, name) {
|
|
|
155
152
|
}
|
|
156
153
|
function handlerPermissions(client, commandType, type) {
|
|
157
154
|
let permissions = [];
|
|
158
|
-
if (commandType ===
|
|
155
|
+
if (commandType === CommandType.MessageCommand) {
|
|
159
156
|
if (type === 'user') permissions = client.handlerOptions.message?.userPermissions || [];
|
|
160
157
|
else if (type === 'client') permissions = client.handlerOptions.message?.clientPermissions || [];
|
|
161
|
-
} else if (commandType ===
|
|
158
|
+
} else if (commandType === CommandType.SlashCommand) {
|
|
162
159
|
if (type === 'user') permissions = client.handlerOptions.slash?.userPermissions || [];
|
|
163
160
|
else if (type === 'client') permissions = client.handlerOptions.slash?.clientPermissions || [];
|
|
164
|
-
} else if (commandType ===
|
|
161
|
+
} else if (commandType === CommandType.ContextCommand) {
|
|
165
162
|
if (type === 'user') permissions = client.handlerOptions.context?.userPermissions || [];
|
|
166
163
|
else if (type === 'client') permissions = client.handlerOptions.context?.clientPermissions || [];
|
|
167
164
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ContextCommandBuilder, MessageCommandBuilder, SlashCommandBuilder } from '../main.js';
|
|
2
|
+
import { XernerxMessage } from '../types/extenders.js';
|
|
3
|
+
import { InhibitorType, XernerxInteraction } from '../types/types.js';
|
|
4
|
+
export declare function inhibitorValidation(event: XernerxMessage | XernerxInteraction, cmd?: ContextCommandBuilder | MessageCommandBuilder | SlashCommandBuilder): Promise<boolean>;
|
|
5
|
+
export declare function inhibitorArguments(
|
|
6
|
+
event: XernerxMessage | XernerxInteraction,
|
|
7
|
+
cmd: ContextCommandBuilder | MessageCommandBuilder | SlashCommandBuilder | null,
|
|
8
|
+
type: InhibitorType
|
|
9
|
+
):
|
|
10
|
+
| import('discord.js').Guild
|
|
11
|
+
| import('discord.js').GuildMember
|
|
12
|
+
| import('discord.js').TextBasedChannel
|
|
13
|
+
| import('discord.js').User
|
|
14
|
+
| SlashCommandBuilder
|
|
15
|
+
| ContextCommandBuilder
|
|
16
|
+
| MessageCommandBuilder
|
|
17
|
+
| import('../main.js').APIInteractionGuildMember
|
|
18
|
+
| null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export async function inhibitorValidation(event, cmd) {
|
|
2
|
+
const client = event.client;
|
|
3
|
+
const inhibits = [];
|
|
4
|
+
for (const [name, inhibitor] of client.inhibitors) {
|
|
5
|
+
if (Boolean(await inhibitor.check(event, await inhibitorArguments(event, cmd || null, inhibitor.type)))) {
|
|
6
|
+
inhibits.push(name);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return !!inhibits.length;
|
|
10
|
+
}
|
|
11
|
+
export function inhibitorArguments(event, cmd, type) {
|
|
12
|
+
switch (type) {
|
|
13
|
+
case 'channel':
|
|
14
|
+
return event.channel || null;
|
|
15
|
+
case 'command':
|
|
16
|
+
return cmd;
|
|
17
|
+
case 'contextCommand':
|
|
18
|
+
return cmd;
|
|
19
|
+
case 'guild':
|
|
20
|
+
return event.guild || null;
|
|
21
|
+
case 'interaction':
|
|
22
|
+
return null;
|
|
23
|
+
case 'member':
|
|
24
|
+
return event.member || null;
|
|
25
|
+
case 'message':
|
|
26
|
+
return null;
|
|
27
|
+
case 'messageCommand':
|
|
28
|
+
return cmd;
|
|
29
|
+
case 'slashCommand':
|
|
30
|
+
return cmd;
|
|
31
|
+
case 'user':
|
|
32
|
+
return event.user;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ContextCommandBuilder from '../build/ContextCommandBuilder.js';
|
|
2
|
+
import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
|
|
3
|
+
import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
|
|
4
|
+
import { XernerxMessage } from '../types/extenders.js';
|
|
5
|
+
import { XernerxInteraction } from '../types/types.js';
|
|
6
|
+
export default function commandValidation(event: XernerxInteraction | XernerxMessage, command: MessageCommandBuilder | SlashCommandBuilder | ContextCommandBuilder): Promise<boolean>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ChannelType, PermissionFlagsBits } from 'discord.js';
|
|
2
|
+
export default async function commandValidation(event, command) {
|
|
3
|
+
const client = event.client;
|
|
4
|
+
if (command.ignore?.owner && client.settings.ownerId.includes(event.user.id)) return false;
|
|
5
|
+
if (!client.cache.cooldowns.has(`${event.user.id}-${command.name}`)) {
|
|
6
|
+
client.cache.cooldowns.set(`${event.user.id}-${command.name}`, {
|
|
7
|
+
id: event.user.id,
|
|
8
|
+
command: command.name,
|
|
9
|
+
createdTimestamp: Number(Date.now()) + (command.cooldown || 0),
|
|
10
|
+
});
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
client.cache.cooldowns.delete(`${event.user.id}-${command.name}`);
|
|
13
|
+
}, command.cooldown || 0);
|
|
14
|
+
} else {
|
|
15
|
+
const user = client.cache.cooldowns.get(`${event.user.id}-${command.name}`);
|
|
16
|
+
const time = (user?.createdTimestamp || 0) - Number(Date.now());
|
|
17
|
+
return emit(event, `Command on cooldown, ${time}`);
|
|
18
|
+
}
|
|
19
|
+
if ((command.ignore?.channels?.length || 0) > 0 && command.ignore?.channels?.includes(event.channel?.id)) return true;
|
|
20
|
+
if ((command.ignore?.guilds?.length || 0) > 0 && command.ignore?.guilds?.includes(event.guild?.id)) return true;
|
|
21
|
+
if ((command.ignore?.users?.length || 0) > 0 && command.ignore?.users?.includes(event.user.id)) return true;
|
|
22
|
+
if (command.strict?.owner && !client.settings.ownerId.includes(event.user.id)) return await emit(event, 'Command is a developer command');
|
|
23
|
+
if ((command.strict?.channels?.length || 0) > 0 && !command.strict?.channels?.includes(event.channel?.id)) return await emit(event, 'Command cannot be ran in this channel');
|
|
24
|
+
if ((command.strict?.guilds?.length || 0) > 0 && !command.strict?.guilds?.includes(event.guild?.id)) return await emit(event, 'Command cannot be ran in this guild');
|
|
25
|
+
if ((command.strict?.users?.length || 0) > 0 && !command.strict?.users?.includes(event.user.id)) return await emit(event, 'Command cannot be ran by you');
|
|
26
|
+
if (command.permissions?.dm == false && event.channel?.type === ChannelType.DM) return await emit(event, "Can't use in a DM Channel");
|
|
27
|
+
if (command.permissions?.user) {
|
|
28
|
+
if (!(event.member?.permissions).has(toBigInt(command.permissions.user))) return await emit(event, 'Missing User Permissions');
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
async function emit(event, reason) {
|
|
33
|
+
return await event.client.emit('commandBlock', event, reason);
|
|
34
|
+
}
|
|
35
|
+
function toBigInt(permissions) {
|
|
36
|
+
let bigIntPermissions = 0n;
|
|
37
|
+
permissions.map((permission) => {
|
|
38
|
+
permission =
|
|
39
|
+
PermissionFlagsBits[
|
|
40
|
+
permission
|
|
41
|
+
.split(/ +/)
|
|
42
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
43
|
+
.join('')
|
|
44
|
+
];
|
|
45
|
+
if (typeof permission === 'bigint') bigIntPermissions += permission;
|
|
46
|
+
});
|
|
47
|
+
return bigIntPermissions;
|
|
48
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
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>;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xernerx",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A bot framework for discord.js.",
|
|
5
|
-
"main": "dist/
|
|
6
|
-
"
|
|
5
|
+
"main": "dist/main.js",
|
|
6
|
+
"type": "module",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"discord.js",
|
|
9
9
|
"discord",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"author": "Dummi",
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"homepage": "https://xernerx.github.io/xernerx
|
|
18
|
+
"homepage": "https://xernerx.github.io/xernerx",
|
|
19
19
|
"packageManager": "npm@8.5.5",
|
|
20
20
|
"scripts": {
|
|
21
21
|
"start": "npm i && npm fund && npm audit fix --force && npm link && tsc -w",
|
|
@@ -26,9 +26,7 @@
|
|
|
26
26
|
"commit": "node ../.scripts/commit.js",
|
|
27
27
|
"write": "npm run build && npm run format && node ../.scripts/rewritePackage.js ",
|
|
28
28
|
"format": "npx prettier --write src dist",
|
|
29
|
-
"build": "
|
|
30
|
-
"build:esm": "tsc",
|
|
31
|
-
"build:cjs": "tsc --module CommonJS --outDir dist/cjs"
|
|
29
|
+
"build": "tsc && npm run format"
|
|
32
30
|
},
|
|
33
31
|
"repository": {
|
|
34
32
|
"type": "git",
|
|
@@ -38,15 +36,13 @@
|
|
|
38
36
|
"url": "https://github.com/xernerx/xernerx/issues"
|
|
39
37
|
},
|
|
40
38
|
"dependencies": {
|
|
41
|
-
"
|
|
42
|
-
"dbl-sdk": "^1.2.0",
|
|
43
|
-
"discord.js": "^14.7.1",
|
|
39
|
+
"discord.js": "^14.9.0",
|
|
44
40
|
"dumfunctions": "^2.1.2",
|
|
45
|
-
"xernerx-extension-builder": "^0.0.
|
|
46
|
-
"zod": "^3.
|
|
41
|
+
"xernerx-extension-builder": "^0.0.9",
|
|
42
|
+
"zod": "^3.21.4"
|
|
47
43
|
},
|
|
48
44
|
"devDependencies": {
|
|
49
|
-
"prettier": "^2.8.
|
|
50
|
-
"typescript": "^
|
|
45
|
+
"prettier": "^2.8.7",
|
|
46
|
+
"typescript": "^5.0.3"
|
|
51
47
|
}
|
|
52
48
|
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { 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 ContextCommandBuilder {
|
|
10
|
-
id: string;
|
|
11
|
-
data: ContextMenuCommandBuilder;
|
|
12
|
-
name: string;
|
|
13
|
-
type: import('@discordjs/builders').ContextMenuCommandType;
|
|
14
|
-
description: string | undefined;
|
|
15
|
-
info: string | undefined;
|
|
16
|
-
category: string | undefined;
|
|
17
|
-
channelType: number | number[] | undefined;
|
|
18
|
-
cooldown: number | undefined;
|
|
19
|
-
ignore:
|
|
20
|
-
| {
|
|
21
|
-
owner?: boolean | undefined;
|
|
22
|
-
users?: string[] | undefined;
|
|
23
|
-
channels?: string[] | undefined;
|
|
24
|
-
guilds?: string[] | undefined;
|
|
25
|
-
}
|
|
26
|
-
| undefined;
|
|
27
|
-
strict:
|
|
28
|
-
| {
|
|
29
|
-
owner?: boolean | undefined;
|
|
30
|
-
users?: string[] | undefined;
|
|
31
|
-
channels?: string[] | undefined;
|
|
32
|
-
guilds?: string[] | undefined;
|
|
33
|
-
}
|
|
34
|
-
| undefined;
|
|
35
|
-
permissions:
|
|
36
|
-
| {
|
|
37
|
-
client?: string[] | undefined;
|
|
38
|
-
users?: string[] | undefined;
|
|
39
|
-
dm?: boolean | undefined;
|
|
40
|
-
}
|
|
41
|
-
| undefined;
|
|
42
|
-
defer:
|
|
43
|
-
| {
|
|
44
|
-
reply?: boolean | undefined;
|
|
45
|
-
ephemeral?: boolean | undefined;
|
|
46
|
-
fetch?: boolean | undefined;
|
|
47
|
-
}
|
|
48
|
-
| undefined;
|
|
49
|
-
client: typeof XernerxClient;
|
|
50
|
-
constructor(id: string, options: ContextCommandOptions);
|
|
51
|
-
/**
|
|
52
|
-
* @param {Interaction} interaction - The Discord interaction event data.
|
|
53
|
-
* @description make any preconditions here.
|
|
54
|
-
* TODO - update description
|
|
55
|
-
*/
|
|
56
|
-
conditions(interaction: Interaction, args: any): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* @param {Interaction} interaction - The Discord interaction event data.
|
|
59
|
-
* @description Make your custom command here.
|
|
60
|
-
* TODO - update description
|
|
61
|
-
*/
|
|
62
|
-
exec(interaction: Interaction, args: any): Promise<void>;
|
|
63
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __importDefault =
|
|
3
|
-
(this && this.__importDefault) ||
|
|
4
|
-
function (mod) {
|
|
5
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8
|
-
const discord_js_1 = require('discord.js');
|
|
9
|
-
const zod_1 = require('zod');
|
|
10
|
-
const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
|
|
11
|
-
/**
|
|
12
|
-
* @description The command builder for context commands.
|
|
13
|
-
* @param {String} id - The unique ID of the command.
|
|
14
|
-
* @param {ContextCommandOptions} options - The command options.
|
|
15
|
-
*/
|
|
16
|
-
class ContextCommandBuilder {
|
|
17
|
-
id;
|
|
18
|
-
data;
|
|
19
|
-
name;
|
|
20
|
-
type;
|
|
21
|
-
description;
|
|
22
|
-
info;
|
|
23
|
-
category;
|
|
24
|
-
channelType;
|
|
25
|
-
cooldown;
|
|
26
|
-
ignore;
|
|
27
|
-
strict;
|
|
28
|
-
permissions;
|
|
29
|
-
defer;
|
|
30
|
-
client;
|
|
31
|
-
constructor(id, options) {
|
|
32
|
-
this.id = id;
|
|
33
|
-
this.data = new discord_js_1.ContextMenuCommandBuilder();
|
|
34
|
-
if (options.name) this.data.setName(options.name);
|
|
35
|
-
if (options.type) this.data.setType(options.type);
|
|
36
|
-
if (options.permissions?.users) this.data.setDefaultMemberPermissions(options.permissions?.users);
|
|
37
|
-
if (options.permissions?.dm === false) this.data.setDMPermission(options.permissions?.dm);
|
|
38
|
-
if (options.nameLocalizations) this.data.setNameLocalizations(options.nameLocalizations);
|
|
39
|
-
zod_1.z
|
|
40
|
-
.object({
|
|
41
|
-
description: zod_1.z.string(),
|
|
42
|
-
info: zod_1.z.string(),
|
|
43
|
-
category: zod_1.z.string(),
|
|
44
|
-
channelType: zod_1.z.array(zod_1.z.number()).or(zod_1.z.number()),
|
|
45
|
-
cooldown: zod_1.z.number(),
|
|
46
|
-
ignore: zod_1.z.object({
|
|
47
|
-
owner: zod_1.z.boolean(),
|
|
48
|
-
users: zod_1.z.array(zod_1.z.string()),
|
|
49
|
-
channels: zod_1.z.array(zod_1.z.string()),
|
|
50
|
-
guilds: zod_1.z.array(zod_1.z.string()),
|
|
51
|
-
}),
|
|
52
|
-
strict: zod_1.z.object({
|
|
53
|
-
owner: zod_1.z.boolean(),
|
|
54
|
-
users: zod_1.z.array(zod_1.z.string()),
|
|
55
|
-
channels: zod_1.z.array(zod_1.z.string()),
|
|
56
|
-
guilds: zod_1.z.array(zod_1.z.string()),
|
|
57
|
-
}),
|
|
58
|
-
permissions: zod_1.z.object({
|
|
59
|
-
client: zod_1.z.array(zod_1.z.string()),
|
|
60
|
-
users: zod_1.z.array(zod_1.z.string()),
|
|
61
|
-
dm: zod_1.z.boolean(),
|
|
62
|
-
}),
|
|
63
|
-
defer: zod_1.z.object({
|
|
64
|
-
reply: zod_1.z.boolean(),
|
|
65
|
-
ephemeral: zod_1.z.boolean(),
|
|
66
|
-
fetch: zod_1.z.boolean(),
|
|
67
|
-
}),
|
|
68
|
-
})
|
|
69
|
-
.deepPartial()
|
|
70
|
-
.parse(options);
|
|
71
|
-
this.name = options.name;
|
|
72
|
-
this.type = options.type;
|
|
73
|
-
this.description = options.description;
|
|
74
|
-
this.info = options.info;
|
|
75
|
-
this.category = options.category;
|
|
76
|
-
this.channelType = options.channelType;
|
|
77
|
-
this.cooldown = options.cooldown;
|
|
78
|
-
this.ignore = options.ignore;
|
|
79
|
-
this.strict = options.strict;
|
|
80
|
-
this.permissions = options.permissions;
|
|
81
|
-
this.defer = options.defer;
|
|
82
|
-
this.client = XernerxClient_js_1.default;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* @param {Interaction} interaction - The Discord interaction event data.
|
|
86
|
-
* @description make any preconditions here.
|
|
87
|
-
* TODO - update description
|
|
88
|
-
*/
|
|
89
|
-
async conditions(interaction, args) {}
|
|
90
|
-
/**
|
|
91
|
-
* @param {Interaction} interaction - The Discord interaction event data.
|
|
92
|
-
* @description Make your custom command here.
|
|
93
|
-
* TODO - update description
|
|
94
|
-
*/
|
|
95
|
-
async exec(interaction, args) {}
|
|
96
|
-
}
|
|
97
|
-
exports.default = ContextCommandBuilder;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __importDefault =
|
|
3
|
-
(this && this.__importDefault) ||
|
|
4
|
-
function (mod) {
|
|
5
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8
|
-
const zod_1 = require('zod');
|
|
9
|
-
const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
|
|
10
|
-
/**
|
|
11
|
-
* @description - The event builder for events.
|
|
12
|
-
* @param {String} id - The unique ID of the event.
|
|
13
|
-
* @param {EventOptions} options - The event options.
|
|
14
|
-
*/
|
|
15
|
-
class EventBuilder {
|
|
16
|
-
id;
|
|
17
|
-
name;
|
|
18
|
-
emitter;
|
|
19
|
-
type;
|
|
20
|
-
once;
|
|
21
|
-
client;
|
|
22
|
-
constructor(id, options) {
|
|
23
|
-
this.id = id;
|
|
24
|
-
zod_1.z
|
|
25
|
-
.object({
|
|
26
|
-
name: zod_1.z.string(),
|
|
27
|
-
emitter: zod_1.z.string().optional(),
|
|
28
|
-
type: zod_1.z.string().optional(),
|
|
29
|
-
once: zod_1.z.boolean().optional(),
|
|
30
|
-
})
|
|
31
|
-
.parse(options);
|
|
32
|
-
this.name = options.name;
|
|
33
|
-
this.emitter = options.emitter || 'client';
|
|
34
|
-
this.type = options.type || 'discord';
|
|
35
|
-
this.once = options.once || false;
|
|
36
|
-
this.client = XernerxClient_js_1.default;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* @description run your custom event here.
|
|
40
|
-
* TODO - update description
|
|
41
|
-
*/
|
|
42
|
-
async run() {}
|
|
43
|
-
}
|
|
44
|
-
exports.default = EventBuilder;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __importDefault =
|
|
3
|
-
(this && this.__importDefault) ||
|
|
4
|
-
function (mod) {
|
|
5
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8
|
-
const zod_1 = require('zod');
|
|
9
|
-
const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
|
|
10
|
-
/**
|
|
11
|
-
* @description - The inhibitor builder for inhibitors.
|
|
12
|
-
* @param {String} id - The unique ID of the inhibitor.
|
|
13
|
-
* @param {InhibitorOptions} options - The inhibitor options.
|
|
14
|
-
*/
|
|
15
|
-
class InhibitorBuilder {
|
|
16
|
-
id;
|
|
17
|
-
name;
|
|
18
|
-
type;
|
|
19
|
-
client;
|
|
20
|
-
constructor(id, options) {
|
|
21
|
-
this.id = id;
|
|
22
|
-
zod_1.z
|
|
23
|
-
.object({
|
|
24
|
-
name: zod_1.z.string(),
|
|
25
|
-
type: zod_1.z.string(),
|
|
26
|
-
})
|
|
27
|
-
.parse(options);
|
|
28
|
-
this.name = options.name;
|
|
29
|
-
this.type = options.type;
|
|
30
|
-
this.client = XernerxClient_js_1.default;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* TODO - update description
|
|
34
|
-
*/
|
|
35
|
-
async check(interaction, args) {}
|
|
36
|
-
}
|
|
37
|
-
exports.default = InhibitorBuilder;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __importDefault =
|
|
3
|
-
(this && this.__importDefault) ||
|
|
4
|
-
function (mod) {
|
|
5
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8
|
-
const zod_1 = require('zod');
|
|
9
|
-
const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
|
|
10
|
-
/**
|
|
11
|
-
* @description - The command builder for message commands.
|
|
12
|
-
* @param {String} id - The unique ID of the command.
|
|
13
|
-
* @param {MessageCommandOptions} options - The command options.
|
|
14
|
-
*/
|
|
15
|
-
class MessageCommandBuilder {
|
|
16
|
-
id;
|
|
17
|
-
name;
|
|
18
|
-
aliases;
|
|
19
|
-
separator;
|
|
20
|
-
description;
|
|
21
|
-
info;
|
|
22
|
-
category;
|
|
23
|
-
prefix;
|
|
24
|
-
regex;
|
|
25
|
-
channelType;
|
|
26
|
-
ignore;
|
|
27
|
-
strict;
|
|
28
|
-
permissions;
|
|
29
|
-
cooldown;
|
|
30
|
-
args;
|
|
31
|
-
client;
|
|
32
|
-
constructor(id, options) {
|
|
33
|
-
this.id = id;
|
|
34
|
-
zod_1.z
|
|
35
|
-
.object({
|
|
36
|
-
name: zod_1.z.string(),
|
|
37
|
-
aliases: zod_1.z.array(zod_1.z.string()).optional(),
|
|
38
|
-
separator: zod_1.z.string().min(1).max(1).optional(),
|
|
39
|
-
description: zod_1.z.string().optional(),
|
|
40
|
-
info: zod_1.z.string().optional(),
|
|
41
|
-
category: zod_1.z.string().optional(),
|
|
42
|
-
prefix: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
|
|
43
|
-
regex: zod_1.z.unknown(),
|
|
44
|
-
channelType: zod_1.z.array(zod_1.z.number()).or(zod_1.z.number()).optional(),
|
|
45
|
-
cooldown: zod_1.z.number().optional(),
|
|
46
|
-
ignore: zod_1.z
|
|
47
|
-
.object({
|
|
48
|
-
owners: zod_1.z.boolean().optional(),
|
|
49
|
-
users: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
|
|
50
|
-
channels: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
|
|
51
|
-
guilds: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
|
|
52
|
-
})
|
|
53
|
-
.optional(),
|
|
54
|
-
strict: zod_1.z
|
|
55
|
-
.object({
|
|
56
|
-
owners: zod_1.z.boolean().optional(),
|
|
57
|
-
users: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
|
|
58
|
-
channels: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
|
|
59
|
-
guilds: zod_1.z.array(zod_1.z.string()).or(zod_1.z.string()).optional(),
|
|
60
|
-
})
|
|
61
|
-
.optional(),
|
|
62
|
-
permissions: zod_1.z
|
|
63
|
-
.object({
|
|
64
|
-
client: zod_1.z.array(zod_1.z.string()).optional(),
|
|
65
|
-
users: zod_1.z.array(zod_1.z.string()).optional(),
|
|
66
|
-
dm: zod_1.z.boolean().optional(),
|
|
67
|
-
})
|
|
68
|
-
.optional(),
|
|
69
|
-
})
|
|
70
|
-
.parse(options);
|
|
71
|
-
this.name = options.name;
|
|
72
|
-
this.aliases = options.aliases;
|
|
73
|
-
this.separator = options.separator || ' ';
|
|
74
|
-
this.description = options.description;
|
|
75
|
-
this.info = options.info;
|
|
76
|
-
this.category = options.category;
|
|
77
|
-
this.prefix = options.prefix ? (Array.isArray(options.prefix) ? options.prefix : [options.prefix]) : [];
|
|
78
|
-
this.regex = options.regex;
|
|
79
|
-
this.channelType = options.channelType;
|
|
80
|
-
this.ignore = options.ignore;
|
|
81
|
-
this.strict = options.strict;
|
|
82
|
-
this.permissions = options.permissions;
|
|
83
|
-
this.cooldown = options.cooldown || 0;
|
|
84
|
-
this.args = options.args || [];
|
|
85
|
-
this.client = XernerxClient_js_1.default;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @param {Message} message - The Discord message event data.
|
|
89
|
-
* @param {object} args - The arguments you created.
|
|
90
|
-
* @description make any preconditions here.
|
|
91
|
-
*/
|
|
92
|
-
async conditions(message, args) {}
|
|
93
|
-
/**
|
|
94
|
-
* @param {Message} message - The Discord message event data.
|
|
95
|
-
* @param {object} args - The arguments you created.
|
|
96
|
-
* @description Make your custom command here.
|
|
97
|
-
*/
|
|
98
|
-
async exec(message, args) {}
|
|
99
|
-
}
|
|
100
|
-
exports.default = MessageCommandBuilder;
|