feat(handlers): added check to owner only command

This commit is contained in:
Slincnik 2025-01-11 13:53:11 +03:00
parent 4a5f4edeb8
commit b0d882f39a
No known key found for this signature in database

View file

@ -3,6 +3,7 @@ import logger from "../../helpers/logger.js";
import { getFilePaths } from "../../utils/index.js";
import { toFileURL } from "../../utils/resolve-file.js";
import registerCommands from "./functions/registerCommands.js";
import { replyError } from "../../helpers/extenders.js";
export class CommandHandler {
constructor(client) {
@ -54,6 +55,13 @@ export class CommandHandler {
const targetCommand = this.commands.find(cmd => cmd.data.name === interaction.commandName);
if (!targetCommand) return;
const ownerId = this.client.configService.get("owner.id");
if (targetCommand.data.ownerOnly && interaction.user.id !== ownerId) {
return replyError(interaction, "misc:OWNER_ONLY", null, { ephemeral: true });
}
// Skip if autocomplete handler is not defined
if (isAutocomplete && !targetCommand.autocompleteRun) return;