commandkit 1.2.0-dev.20250918033758 → 1.2.0-dev.20250918124943
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/{MessageCommandParser-3B07fEIF.js → MessageCommandParser-Dl0xxtdr.js} +1 -1
- package/dist/{MessageCommandParser-3B07fEIF.js.map → MessageCommandParser-Dl0xxtdr.js.map} +1 -1
- package/dist/analytics/analytics-engine.js +3 -3
- package/dist/analytics/utils.js +3 -3
- package/dist/app/commands/AppCommandRunner.js +3 -3
- package/dist/app/commands/Context.js +3 -3
- package/dist/app/commands/MessageCommandParser.js +1 -1
- package/dist/app/commands/helpers.js +1 -1
- package/dist/app/handlers/AppCommandHandler.js +3 -3
- package/dist/app/handlers/AppEventsHandler.js +3 -3
- package/dist/app/index.js +3 -3
- package/dist/app/middlewares/permissions.js +3 -3
- package/dist/app/register/CommandRegistrar.js +3 -3
- package/dist/{build-zQF2x_R5.js → build-DB_aX5xt.js} +2 -2
- package/dist/{build-zQF2x_R5.js.map → build-DB_aX5xt.js.map} +1 -1
- package/dist/cli/build.js +4 -4
- package/dist/cli/development.js +4 -4
- package/dist/cli/information.js +1 -1
- package/dist/cli/init.js +4 -4
- package/dist/cli/production.js +4 -4
- package/dist/{commandkit-DlHcqmKe.js → commandkit-lhbfAyX9.js} +83 -78
- package/dist/{commandkit-DlHcqmKe.js.map → commandkit-lhbfAyX9.js.map} +1 -1
- package/dist/commandkit.js +3 -3
- package/dist/components/index.js +3 -3
- package/dist/components/v1/button/Button.js +3 -3
- package/dist/components/v1/button/ButtonKit.js +3 -3
- package/dist/components/v1/modal/Modal.js +3 -3
- package/dist/components/v1/modal/ModalKit.js +3 -3
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +3 -3
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +3 -3
- package/dist/components/v1/select-menu/RoleSelectMenuKit.js +3 -3
- package/dist/components/v1/select-menu/SelectMenu.js +3 -3
- package/dist/components/v1/select-menu/StringSelectMenuKit.js +3 -3
- package/dist/components/v1/select-menu/UserSelectMenuKit.js +3 -3
- package/dist/config/config.js +3 -3
- package/dist/config/default.js +3 -3
- package/dist/config/loader.js +3 -3
- package/dist/context/async-context.js +3 -3
- package/dist/context/environment.js +3 -3
- package/dist/{feature-flags--YoV7bak.js → feature-flags-DnnKABHf.js} +2 -2
- package/dist/{feature-flags--YoV7bak.js.map → feature-flags-DnnKABHf.js.map} +1 -1
- package/dist/flags/feature-flags.js +4 -4
- package/dist/{helpers-BSwwrKJW.js → helpers-Dl8wW6aO.js} +1 -1
- package/dist/{helpers-BSwwrKJW.js.map → helpers-Dl8wW6aO.js.map} +1 -1
- package/dist/index.js +6 -6
- package/dist/{init-Bg7al5ha.js → init-CY7OJPF-.js} +2 -2
- package/dist/{init-Bg7al5ha.js.map → init-CY7OJPF-.js.map} +1 -1
- package/dist/logger/DefaultLogger.js +3 -3
- package/dist/logger/Logger.js +3 -3
- package/dist/plugins/index.js +3 -3
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +3 -3
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +3 -3
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +3 -3
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +3 -3
- package/dist/utils/dev-hooks.js +3 -3
- package/dist/utils/utilities.js +3 -3
- package/dist/{version-DFQr6AR9.js → version-BwSzsYpw.js} +2 -2
- package/dist/{version-DFQr6AR9.js.map → version-BwSzsYpw.js.map} +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -12,8 +12,8 @@ const require_types_package = require('./types-package-BWArjyBF.js');
|
|
|
12
12
|
const require_constants$1 = require('./constants-BOOGN85p.js');
|
|
13
13
|
const require_EventWorkerContext = require('./EventWorkerContext-Dq29tieI.js');
|
|
14
14
|
const require_signals = require('./signals-ChFMD7mB.js');
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const require_helpers = require('./helpers-Dl8wW6aO.js');
|
|
16
|
+
const require_MessageCommandParser = require('./MessageCommandParser-Dl0xxtdr.js');
|
|
17
17
|
const require_CommandsRouter = require('./CommandsRouter-Dmzw-ikm.js');
|
|
18
18
|
const require_EventsRouter = require('./EventsRouter-3Gygh-km.js');
|
|
19
19
|
const require_common = require('./common-CrqwC-sx.js');
|
|
@@ -2632,6 +2632,81 @@ var AppCommandRunner = class {
|
|
|
2632
2632
|
}
|
|
2633
2633
|
};
|
|
2634
2634
|
|
|
2635
|
+
//#endregion
|
|
2636
|
+
//#region src/app/middlewares/permissions.ts
|
|
2637
|
+
const middlewareId = crypto.randomUUID();
|
|
2638
|
+
/**
|
|
2639
|
+
* @private
|
|
2640
|
+
* @ignore
|
|
2641
|
+
*/
|
|
2642
|
+
async function beforeExecute(ctx) {
|
|
2643
|
+
var _interaction$channel, _message$channel, _message$member, _command$metadata, _interaction$guild, _message$guild, _command$metadata2;
|
|
2644
|
+
if (getConfig().disablePermissionsMiddleware) return;
|
|
2645
|
+
const { interaction, message, command } = ctx;
|
|
2646
|
+
if (interaction && !interaction.isCommand()) return;
|
|
2647
|
+
if (interaction && ((_interaction$channel = interaction.channel) === null || _interaction$channel === void 0 ? void 0 : _interaction$channel.isDMBased()) || message && ((_message$channel = message.channel) === null || _message$channel === void 0 ? void 0 : _message$channel.isDMBased())) {
|
|
2648
|
+
const channel = (interaction === null || interaction === void 0 ? void 0 : interaction.channel) ?? (message === null || message === void 0 ? void 0 : message.channel);
|
|
2649
|
+
const embed$1 = new discord_js.EmbedBuilder().setTitle(":x: Server-only command!").setDescription("This command can only be used in a server.").setColor("Red");
|
|
2650
|
+
try {
|
|
2651
|
+
if (channel === null || channel === void 0 ? void 0 : channel.isSendable()) if (interaction && interaction.isRepliable()) await interaction.reply({
|
|
2652
|
+
embeds: [embed$1],
|
|
2653
|
+
flags: discord_js.MessageFlags.Ephemeral
|
|
2654
|
+
});
|
|
2655
|
+
else await message.reply({ embeds: [embed$1] });
|
|
2656
|
+
} catch (error) {
|
|
2657
|
+
Logger.error`Could not send 'Server-only command' DM to user ${(interaction === null || interaction === void 0 ? void 0 : interaction.user.id) ?? (message === null || message === void 0 ? void 0 : message.author.id)} for command ${command.command.name}: ${error}`;
|
|
2658
|
+
}
|
|
2659
|
+
require_signals.stopMiddlewares();
|
|
2660
|
+
}
|
|
2661
|
+
const userPermissions = (interaction === null || interaction === void 0 ? void 0 : interaction.memberPermissions) ?? (message === null || message === void 0 || (_message$member = message.member) === null || _message$member === void 0 ? void 0 : _message$member.permissions);
|
|
2662
|
+
let userPermissionsRequired = ((_command$metadata = command.metadata) === null || _command$metadata === void 0 ? void 0 : _command$metadata.userPermissions) ?? [];
|
|
2663
|
+
let missingUserPermissions = [];
|
|
2664
|
+
if (typeof userPermissionsRequired === "string") userPermissionsRequired = [userPermissionsRequired];
|
|
2665
|
+
const botPermissions = (interaction === null || interaction === void 0 || (_interaction$guild = interaction.guild) === null || _interaction$guild === void 0 || (_interaction$guild = _interaction$guild.members.me) === null || _interaction$guild === void 0 ? void 0 : _interaction$guild.permissions) ?? (message === null || message === void 0 || (_message$guild = message.guild) === null || _message$guild === void 0 || (_message$guild = _message$guild.members.me) === null || _message$guild === void 0 ? void 0 : _message$guild.permissions);
|
|
2666
|
+
let botPermissionsRequired = ((_command$metadata2 = command.metadata) === null || _command$metadata2 === void 0 ? void 0 : _command$metadata2.botPermissions) ?? [];
|
|
2667
|
+
let missingBotPermissions = [];
|
|
2668
|
+
if (typeof botPermissionsRequired === "string") botPermissionsRequired = [botPermissionsRequired];
|
|
2669
|
+
if (!userPermissionsRequired.length && !botPermissionsRequired.length) return;
|
|
2670
|
+
if (userPermissionsRequired.length) {
|
|
2671
|
+
for (const permission of userPermissionsRequired) if (!(userPermissions === null || userPermissions === void 0 ? void 0 : userPermissions.has(permission))) missingUserPermissions.push(permission);
|
|
2672
|
+
}
|
|
2673
|
+
if (botPermissionsRequired.length) {
|
|
2674
|
+
for (const permission of botPermissionsRequired) if (!(botPermissions === null || botPermissions === void 0 ? void 0 : botPermissions.has(permission))) missingBotPermissions.push(permission);
|
|
2675
|
+
}
|
|
2676
|
+
if (!missingUserPermissions.length && !missingBotPermissions.length) return;
|
|
2677
|
+
const pattern = /([a-z])([A-Z])|([A-Z]+)([A-Z][a-z])/g;
|
|
2678
|
+
missingUserPermissions = missingUserPermissions.map((str) => str.replace(pattern, "$1$3 $2$4"));
|
|
2679
|
+
missingBotPermissions = missingBotPermissions.map((str) => str.replace(pattern, "$1$3 $2$4"));
|
|
2680
|
+
let embedDescription = "";
|
|
2681
|
+
const formatter = new Intl.ListFormat("en", {
|
|
2682
|
+
style: "long",
|
|
2683
|
+
type: "conjunction"
|
|
2684
|
+
});
|
|
2685
|
+
const getPermissionWord = (permissions) => permissions.length === 1 ? "permission" : "permissions";
|
|
2686
|
+
if (missingUserPermissions.length) {
|
|
2687
|
+
const formattedPermissions = missingUserPermissions.map((p) => `\`${p}\``);
|
|
2688
|
+
const permissionsString = formatter.format(formattedPermissions);
|
|
2689
|
+
embedDescription += `- You must have the ${permissionsString} ${getPermissionWord(missingUserPermissions)} to be able to run this command.\n`;
|
|
2690
|
+
}
|
|
2691
|
+
if (missingBotPermissions.length) {
|
|
2692
|
+
const formattedPermissions = missingBotPermissions.map((p) => `\`${p}\``);
|
|
2693
|
+
const permissionsString = formatter.format(formattedPermissions);
|
|
2694
|
+
embedDescription += `- I must have the ${permissionsString} ${getPermissionWord(missingBotPermissions)} to be able to execute this command.\n`;
|
|
2695
|
+
}
|
|
2696
|
+
const embed = new discord_js.EmbedBuilder().setTitle(`:x: Missing permissions!`).setDescription(embedDescription).setColor("Red");
|
|
2697
|
+
try {
|
|
2698
|
+
var _message$channel2;
|
|
2699
|
+
if (interaction && interaction.isRepliable()) await interaction.reply({
|
|
2700
|
+
embeds: [embed],
|
|
2701
|
+
flags: discord_js.MessageFlags.Ephemeral
|
|
2702
|
+
});
|
|
2703
|
+
else if (message && ((_message$channel2 = message.channel) === null || _message$channel2 === void 0 ? void 0 : _message$channel2.isSendable())) await message.reply({ embeds: [embed] });
|
|
2704
|
+
} catch (error) {
|
|
2705
|
+
Logger.error`Could not send 'Not enough permissions' reply to user ${(interaction === null || interaction === void 0 ? void 0 : interaction.user.id) ?? (message === null || message === void 0 ? void 0 : message.author.id)} for command ${command.command.name}: ${error}`;
|
|
2706
|
+
}
|
|
2707
|
+
require_signals.stopMiddlewares();
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2635
2710
|
//#endregion
|
|
2636
2711
|
//#region src/app/register/CommandRegistrar.ts
|
|
2637
2712
|
/**
|
|
@@ -2805,81 +2880,6 @@ var CommandRegistrar = class {
|
|
|
2805
2880
|
}
|
|
2806
2881
|
};
|
|
2807
2882
|
|
|
2808
|
-
//#endregion
|
|
2809
|
-
//#region src/app/middlewares/permissions.ts
|
|
2810
|
-
const middlewareId = crypto.randomUUID();
|
|
2811
|
-
/**
|
|
2812
|
-
* @private
|
|
2813
|
-
* @ignore
|
|
2814
|
-
*/
|
|
2815
|
-
async function beforeExecute(ctx) {
|
|
2816
|
-
var _interaction$channel, _message$channel, _message$member, _command$metadata, _interaction$guild, _message$guild, _command$metadata2;
|
|
2817
|
-
if (getConfig().disablePermissionsMiddleware) return;
|
|
2818
|
-
const { interaction, message, command } = ctx;
|
|
2819
|
-
if (interaction && !interaction.isCommand()) return;
|
|
2820
|
-
if (interaction && ((_interaction$channel = interaction.channel) === null || _interaction$channel === void 0 ? void 0 : _interaction$channel.isDMBased()) || message && ((_message$channel = message.channel) === null || _message$channel === void 0 ? void 0 : _message$channel.isDMBased())) {
|
|
2821
|
-
const channel = (interaction === null || interaction === void 0 ? void 0 : interaction.channel) ?? (message === null || message === void 0 ? void 0 : message.channel);
|
|
2822
|
-
const embed$1 = new discord_js.EmbedBuilder().setTitle(":x: Server-only command!").setDescription("This command can only be used in a server.").setColor("Red");
|
|
2823
|
-
try {
|
|
2824
|
-
if (channel === null || channel === void 0 ? void 0 : channel.isSendable()) if (interaction && interaction.isRepliable()) await interaction.reply({
|
|
2825
|
-
embeds: [embed$1],
|
|
2826
|
-
flags: discord_js.MessageFlags.Ephemeral
|
|
2827
|
-
});
|
|
2828
|
-
else await message.reply({ embeds: [embed$1] });
|
|
2829
|
-
} catch (error) {
|
|
2830
|
-
Logger.error`Could not send 'Server-only command' DM to user ${(interaction === null || interaction === void 0 ? void 0 : interaction.user.id) ?? (message === null || message === void 0 ? void 0 : message.author.id)} for command ${command.command.name}: ${error}`;
|
|
2831
|
-
}
|
|
2832
|
-
require_signals.stopMiddlewares();
|
|
2833
|
-
}
|
|
2834
|
-
const userPermissions = (interaction === null || interaction === void 0 ? void 0 : interaction.memberPermissions) ?? (message === null || message === void 0 || (_message$member = message.member) === null || _message$member === void 0 ? void 0 : _message$member.permissions);
|
|
2835
|
-
let userPermissionsRequired = ((_command$metadata = command.metadata) === null || _command$metadata === void 0 ? void 0 : _command$metadata.userPermissions) ?? [];
|
|
2836
|
-
let missingUserPermissions = [];
|
|
2837
|
-
if (typeof userPermissionsRequired === "string") userPermissionsRequired = [userPermissionsRequired];
|
|
2838
|
-
const botPermissions = (interaction === null || interaction === void 0 || (_interaction$guild = interaction.guild) === null || _interaction$guild === void 0 || (_interaction$guild = _interaction$guild.members.me) === null || _interaction$guild === void 0 ? void 0 : _interaction$guild.permissions) ?? (message === null || message === void 0 || (_message$guild = message.guild) === null || _message$guild === void 0 || (_message$guild = _message$guild.members.me) === null || _message$guild === void 0 ? void 0 : _message$guild.permissions);
|
|
2839
|
-
let botPermissionsRequired = ((_command$metadata2 = command.metadata) === null || _command$metadata2 === void 0 ? void 0 : _command$metadata2.botPermissions) ?? [];
|
|
2840
|
-
let missingBotPermissions = [];
|
|
2841
|
-
if (typeof botPermissionsRequired === "string") botPermissionsRequired = [botPermissionsRequired];
|
|
2842
|
-
if (!userPermissionsRequired.length && !botPermissionsRequired.length) return;
|
|
2843
|
-
if (userPermissionsRequired.length) {
|
|
2844
|
-
for (const permission of userPermissionsRequired) if (!(userPermissions === null || userPermissions === void 0 ? void 0 : userPermissions.has(permission))) missingUserPermissions.push(permission);
|
|
2845
|
-
}
|
|
2846
|
-
if (botPermissionsRequired.length) {
|
|
2847
|
-
for (const permission of botPermissionsRequired) if (!(botPermissions === null || botPermissions === void 0 ? void 0 : botPermissions.has(permission))) missingBotPermissions.push(permission);
|
|
2848
|
-
}
|
|
2849
|
-
if (!missingUserPermissions.length && !missingBotPermissions.length) return;
|
|
2850
|
-
const pattern = /([a-z])([A-Z])|([A-Z]+)([A-Z][a-z])/g;
|
|
2851
|
-
missingUserPermissions = missingUserPermissions.map((str) => str.replace(pattern, "$1$3 $2$4"));
|
|
2852
|
-
missingBotPermissions = missingBotPermissions.map((str) => str.replace(pattern, "$1$3 $2$4"));
|
|
2853
|
-
let embedDescription = "";
|
|
2854
|
-
const formatter = new Intl.ListFormat("en", {
|
|
2855
|
-
style: "long",
|
|
2856
|
-
type: "conjunction"
|
|
2857
|
-
});
|
|
2858
|
-
const getPermissionWord = (permissions) => permissions.length === 1 ? "permission" : "permissions";
|
|
2859
|
-
if (missingUserPermissions.length) {
|
|
2860
|
-
const formattedPermissions = missingUserPermissions.map((p) => `\`${p}\``);
|
|
2861
|
-
const permissionsString = formatter.format(formattedPermissions);
|
|
2862
|
-
embedDescription += `- You must have the ${permissionsString} ${getPermissionWord(missingUserPermissions)} to be able to run this command.\n`;
|
|
2863
|
-
}
|
|
2864
|
-
if (missingBotPermissions.length) {
|
|
2865
|
-
const formattedPermissions = missingBotPermissions.map((p) => `\`${p}\``);
|
|
2866
|
-
const permissionsString = formatter.format(formattedPermissions);
|
|
2867
|
-
embedDescription += `- I must have the ${permissionsString} ${getPermissionWord(missingBotPermissions)} to be able to execute this command.\n`;
|
|
2868
|
-
}
|
|
2869
|
-
const embed = new discord_js.EmbedBuilder().setTitle(`:x: Missing permissions!`).setDescription(embedDescription).setColor("Red");
|
|
2870
|
-
try {
|
|
2871
|
-
var _message$channel2;
|
|
2872
|
-
if (interaction && interaction.isRepliable()) await interaction.reply({
|
|
2873
|
-
embeds: [embed],
|
|
2874
|
-
flags: discord_js.MessageFlags.Ephemeral
|
|
2875
|
-
});
|
|
2876
|
-
else if (message && ((_message$channel2 = message.channel) === null || _message$channel2 === void 0 ? void 0 : _message$channel2.isSendable())) await message.reply({ embeds: [embed] });
|
|
2877
|
-
} catch (error) {
|
|
2878
|
-
Logger.error`Could not send 'Not enough permissions' reply to user ${(interaction === null || interaction === void 0 ? void 0 : interaction.user.id) ?? (message === null || message === void 0 ? void 0 : message.author.id)} for command ${command.command.name}: ${error}`;
|
|
2879
|
-
}
|
|
2880
|
-
require_signals.stopMiddlewares();
|
|
2881
|
-
}
|
|
2882
|
-
|
|
2883
2883
|
//#endregion
|
|
2884
2884
|
//#region src/app/handlers/AppCommandHandler.ts
|
|
2885
2885
|
const KNOWN_NON_HANDLER_KEYS = [
|
|
@@ -3107,6 +3107,11 @@ var AppCommandHandler = class {
|
|
|
3107
3107
|
const loadedCommand = this.findCommandByName(cmdName, hint);
|
|
3108
3108
|
if (!loadedCommand) return null;
|
|
3109
3109
|
if ((source instanceof discord_js.CommandInteraction || source instanceof discord_js.AutocompleteInteraction) && source.guildId && ((_loadedCommand$metada3 = loadedCommand.metadata) === null || _loadedCommand$metada3 === void 0 || (_loadedCommand$metada3 = _loadedCommand$metada3.guilds) === null || _loadedCommand$metada3 === void 0 ? void 0 : _loadedCommand$metada3.length) && !((_loadedCommand$metada4 = loadedCommand.metadata) === null || _loadedCommand$metada4 === void 0 ? void 0 : _loadedCommand$metada4.guilds.includes(source.guildId))) return null;
|
|
3110
|
+
if (source instanceof discord_js.Message) {
|
|
3111
|
+
var _loadedCommand$metada5;
|
|
3112
|
+
if (!source.guildId) return null;
|
|
3113
|
+
if (((_loadedCommand$metada5 = loadedCommand.metadata) === null || _loadedCommand$metada5 === void 0 || (_loadedCommand$metada5 = _loadedCommand$metada5.guilds) === null || _loadedCommand$metada5 === void 0 ? void 0 : _loadedCommand$metada5.length) && !loadedCommand.metadata.guilds.includes(source.guildId)) return null;
|
|
3114
|
+
}
|
|
3110
3115
|
const middlewares = [];
|
|
3111
3116
|
for (const middlewareId$1 of loadedCommand.command.middlewares) {
|
|
3112
3117
|
const middleware = this.loadedMiddlewares.get(middlewareId$1);
|
|
@@ -4477,4 +4482,4 @@ Object.defineProperty(exports, 'useStore', {
|
|
|
4477
4482
|
return useStore;
|
|
4478
4483
|
}
|
|
4479
4484
|
});
|
|
4480
|
-
//# sourceMappingURL=commandkit-
|
|
4485
|
+
//# sourceMappingURL=commandkit-lhbfAyX9.js.map
|