From b0d882f39a64f1913bf55dfdd50a6f60137157cf Mon Sep 17 00:00:00 2001 From: Slincnik Date: Sat, 11 Jan 2025 13:53:11 +0300 Subject: [PATCH] feat(handlers): added check to owner only command --- src/handlers/command-handler/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/handlers/command-handler/index.js b/src/handlers/command-handler/index.js index cbd09e04..7faf5b28 100644 --- a/src/handlers/command-handler/index.js +++ b/src/handlers/command-handler/index.js @@ -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;