feat(commands): added some default options
This commit is contained in:
parent
1f3e427523
commit
15e55c1349
2 changed files with 17 additions and 8 deletions
|
@ -14,6 +14,9 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue