mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-01-19 17:03:47 +05:00
feat(handlers): added check to owner only command
This commit is contained in:
parent
4a5f4edeb8
commit
b0d882f39a
1 changed files with 8 additions and 0 deletions
|
@ -3,6 +3,7 @@ import logger from "../../helpers/logger.js";
|
||||||
import { getFilePaths } from "../../utils/index.js";
|
import { getFilePaths } from "../../utils/index.js";
|
||||||
import { toFileURL } from "../../utils/resolve-file.js";
|
import { toFileURL } from "../../utils/resolve-file.js";
|
||||||
import registerCommands from "./functions/registerCommands.js";
|
import registerCommands from "./functions/registerCommands.js";
|
||||||
|
import { replyError } from "../../helpers/extenders.js";
|
||||||
|
|
||||||
export class CommandHandler {
|
export class CommandHandler {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
|
@ -54,6 +55,13 @@ export class CommandHandler {
|
||||||
const targetCommand = this.commands.find(cmd => cmd.data.name === interaction.commandName);
|
const targetCommand = this.commands.find(cmd => cmd.data.name === interaction.commandName);
|
||||||
|
|
||||||
if (!targetCommand) return;
|
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
|
// Skip if autocomplete handler is not defined
|
||||||
if (isAutocomplete && !targetCommand.autocompleteRun) return;
|
if (isAutocomplete && !targetCommand.autocompleteRun) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue