diff --git a/src/lib/structures/command.ts b/src/lib/structures/command.ts index b01250b..52059d7 100644 --- a/src/lib/structures/command.ts +++ b/src/lib/structures/command.ts @@ -14,6 +14,9 @@ * You should have received a copy of the GNU General Public License * along with ArgonBot. If not, see . */ +import path from 'path'; +import config from 'config'; + import type { Client, Message } from 'discord.js'; import type { ICommandOptions } from '@utils/types'; @@ -21,9 +24,15 @@ export default abstract class Command { public readonly client: Client; public readonly options: ICommandOptions; - protected constructor(client: Client, options: ICommandOptions) { + protected constructor(client: Client, options?: ICommandOptions) { this.client = client; - this.options = options; + + const defaultOptions: ICommandOptions = { + name: path.basename(__filename, path.extname(__filename)), + group: path.basename(path.dirname(__filename)) === 'commands' ? '' : path.basename(path.dirname(__filename)), + }; + + this.options = config.util.extendDeep(defaultOptions, options); } public abstract run(message: Message, ...args: string[]): void; diff --git a/src/lib/utils/types.ts b/src/lib/utils/types.ts index c4a324a..9c4cfaf 100644 --- a/src/lib/utils/types.ts +++ b/src/lib/utils/types.ts @@ -31,12 +31,12 @@ export enum ECommandRunIn { // Interfaces export interface ICommandOptions { - name: string; - shortDescription: string; - extendedDescription: string; - group: string; - ownerOnly: boolean; - runIn: ECommandRunIn; + name?: string; + shortDescription?: string; + extendedDescription?: string; + group?: string; + ownerOnly?: boolean; + runIn?: ECommandRunIn; } // Type Aliases