Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
notunderctrl committed Nov 24, 2023
1 parent 3084bbd commit bcbd184
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 263 deletions.
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ dist
README.md
pnpm-lock.yaml

package.json

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down
112 changes: 56 additions & 56 deletions packages/commandkit/package.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
{
"name": "commandkit",
"description": "Beginner friendly command & event handler for Discord.js",
"version": "0.1.6",
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"bin": "./bin/index.mjs",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
"name": "commandkit",
"description": "Beginner friendly command & event handler for Discord.js",
"version": "0.1.6",
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"bin": "./bin/index.mjs",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
},
"files": [
"dist",
"bin"
],
"scripts": {
"lint": "tsc",
"dev": "tsup --watch",
"build": "tsup",
"deploy": "npm publish",
"deploy-dev": "npm publish --access public --tag dev",
"test": "cd ./tests && node ../bin/index.mjs dev",
"test:build": "cd ./tests && node ../bin/index.mjs build",
"test:prod": "cd ./tests && node ../bin/index.mjs start"
},
"repository": {
"url": "git+https://github.com/underctrl-io/commandkit.git"
},
"homepage": "https://commandkit.js.org",
"keywords": [
"discord.js",
"command handler",
"event handler"
],
"dependencies": {
"commander": "^11.1.0",
"ora": "^7.0.1",
"rfdc": "^1.3.0",
"rimraf": "^5.0.5",
"tsup": "^7.2.0"
},
"devDependencies": {
"@types/node": "^20.5.9",
"discord.js": "^14.13.0",
"dotenv": "^16.3.1",
"tsconfig": "workspace:*",
"tsx": "^3.12.8",
"typescript": "^5.1.6"
},
"peerDependencies": {
"discord.js": "^14"
}
},
"files": [
"dist",
"bin"
],
"scripts": {
"lint": "tsc",
"dev": "tsup --watch",
"build": "tsup",
"deploy": "npm publish",
"deploy-dev": "npm publish --access public --tag dev",
"test": "cd ./tests && node ../bin/index.mjs dev",
"test:build": "cd ./tests && node ../bin/index.mjs build",
"test:prod": "cd ./tests && node ../bin/index.mjs start"
},
"repository": {
"url": "git+https://github.com/underctrl-io/commandkit.git"
},
"homepage": "https://commandkit.js.org",
"keywords": [
"discord.js",
"command handler",
"event handler"
],
"dependencies": {
"commander": "^11.1.0",
"ora": "^7.0.1",
"rfdc": "^1.3.0",
"rimraf": "^5.0.5",
"tsup": "^7.2.0"
},
"devDependencies": {
"@types/node": "^20.5.9",
"discord.js": "^14.13.0",
"dotenv": "^16.3.1",
"tsconfig": "workspace:*",
"tsx": "^3.12.8",
"typescript": "^5.1.6"
},
"peerDependencies": {
"discord.js": "^14"
}
}
}
9 changes: 6 additions & 3 deletions packages/commandkit/src/CommandKit.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import type { CommandObject } from './types';
import type { CommandKitData, CommandKitOptions, ReloadOptions } from './typings';
import type { CommandObject } from './types';

import { CommandHandler, EventHandler, ValidationHandler } from './handlers';

import colors from './utils/colors';

export class CommandKit {
#data: CommandKitData;

/**
* Create a new handler with CommandKit.
* @param options - Options to use (client, commandsPath, eventsPath, etc.)
* Create a new command and event handler with CommandKit.
*
* @param options - The default CommandKit configuration.
* @see {@link https://commandkit.js.org/docs/commandkit-setup}
*/
constructor(options: CommandKitOptions) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { CommandHandlerData, CommandHandlerOptions } from './typings';
import type { CommandFileObject, ReloadOptions } from '../../typings';

import { getFilePaths } from '../../utils/get-paths';
import { toFileURL } from '../../utils/resolve-file-url';
import { getFilePaths } from '../../utils/get-paths';

import loadCommandsWithRest from './functions/loadCommandsWithRest';
import registerCommands from './functions/registerCommands';
import builtInValidations from './validations';
import colors from '../../utils/colors';

import rdfc from 'rfdc';

const clone = rdfc();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import devOnly from './devOnly';
import guildOnly from './guildOnly';
import permissions from './permissions';

export default [devOnly, guildOnly, permissions];
export default [devOnly, permissions];
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ export default function ({ interaction, targetCommand }: BuiltInValidationParams
let userPermissionsRequired = targetCommand.options?.userPermissions;
let missingUserPermissions: string[] = [];

if (typeof userPermissionsRequired === 'string') {
userPermissionsRequired = [userPermissionsRequired];
}

const botPermissions = interaction.guild?.members.me?.permissions;
let botPermissionsRequired = targetCommand.options?.botPermissions;
let missingBotPermissions: string[] = [];

if (typeof botPermissionsRequired === 'string') {
botPermissionsRequired = [botPermissionsRequired];
}

if (!userPermissionsRequired?.length && !botPermissionsRequired?.length) {
return;
}
Expand Down
Loading

0 comments on commit bcbd184

Please sign in to comment.