mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-01-19 17:03:47 +05:00
fix: devOnly validation
This commit is contained in:
parent
6c7f892ae4
commit
ceea161dc4
3 changed files with 16 additions and 2 deletions
|
@ -34,7 +34,7 @@ export class CommandHandler {
|
|||
const commandFilePaths = (await getFilePaths(cmdPath, true)).filter(path => path.endsWith(".js") || path.endsWith(".ts"));
|
||||
|
||||
for (const cmdFilePath of commandFilePaths) {
|
||||
const { data, run } = await import(toFileURL(cmdFilePath));
|
||||
const { data, run, options } = await import(toFileURL(cmdFilePath));
|
||||
|
||||
if (!data || !data.name) {
|
||||
logger.warn(`Command ${cmdFilePath} does not have a data object or name`);
|
||||
|
@ -46,7 +46,7 @@ export class CommandHandler {
|
|||
continue;
|
||||
}
|
||||
|
||||
this.commands.push({ data, run });
|
||||
this.commands.push({ data, run, options });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { BuiltInValidationParams } from "@/types.js";
|
||||
import { ChannelType } from "discord.js";
|
||||
|
||||
export default function ({ interaction, targetCommand, client }: BuiltInValidationParams) {
|
||||
if (interaction.isAutocomplete()) return;
|
||||
|
@ -7,6 +8,17 @@ export default function ({ interaction, targetCommand, client }: BuiltInValidati
|
|||
|
||||
if (!targetCommand.options?.devOnly) return;
|
||||
|
||||
if (!interaction.isRepliable()) return;
|
||||
|
||||
if (interaction.channel?.type === ChannelType.DM) {
|
||||
interaction.reply({
|
||||
content: "❌ This command is only available in development servers.",
|
||||
ephemeral: true,
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (interaction.inGuild() && !devGuildsIds.includes(interaction.guildId)) {
|
||||
interaction.reply({
|
||||
content: "❌ This command is only available in development servers.",
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { ExtendedClient } from "./structures/client.js";
|
||||
import logger from "./helpers/logger.js";
|
||||
import { CLIENT_INTENTS, CLIENT_ALLOWED_MENTIONS } from "./constants/index.js";
|
||||
import { Partials } from "discord.js";
|
||||
|
||||
const client = new ExtendedClient({
|
||||
intents: CLIENT_INTENTS,
|
||||
partials: [Partials.Channel],
|
||||
allowedMentions: CLIENT_ALLOWED_MENTIONS,
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue