Command Structure
Extending the Command
class
Extending the class is easy and you can add as many properties as you like, just don’t touch what is already in the Command class.
export interface interface MyOptions
MyOptions extends (alias) interface CommandOptionsimport CommandOptions
Represents the options for creating a command
CommandOptions { MyOptions.code: () => unknown
code: (/* Type definitions of your arguments */) => unknown}
export class class MyCommand<Options extends MyOptions>
MyCommand<function (type parameter) Options in MyCommand<Options extends MyOptions>
Options extends interface MyOptions
MyOptions> extends class Command<Options extends CommandOptions>
Represents an abstract class of a command.
This is intended to be extended with other things including the function to execute the command, i.e. code(...)
, exec(...)
, etc.
Command<function (type parameter) Options in MyCommand<Options extends MyOptions>
Options> { MyCommand<Options extends MyOptions>.code: () => unknown
code: (/* Type definitions of your arguments */) => unknown; constructor(options: Options extends MyOptions
Options to upload commands, this must be a fix and is only available for chat commands.
options: function (type parameter) Options in MyCommand<Options extends MyOptions>
Options) { super(options: Options extends MyOptions
Options to upload commands, this must be a fix and is only available for chat commands.
options); this.MyCommand<Options extends MyOptions>.code: () => unknown
code = options: Options extends MyOptions
Options to upload commands, this must be a fix and is only available for chat commands.
options.MyOptions.code: () => unknown
code; }}
any
exports.any
MyCommand = class function (local class) MyCommand
MyCommand extends class Command<Options extends CommandOptions>
Represents an abstract class of a command.
This is intended to be extended with other things including the function to execute the command, i.e. code(...)
, exec(...)
, etc.
Command { constructor(options: any
Options to upload commands, this must be a fix and is only available for chat commands.
options) { super(options: any
Options to upload commands, this must be a fix and is only available for chat commands.
options); this.MyCommand.code: any
code = options: any
Options to upload commands, this must be a fix and is only available for chat commands.
options.any
code; }}
As you can see, we set code
as a function, with this logic you can add as many properties and functions as you like.
Your First Command
Just now we will see how you can use your MyCommand
class.
export default new constructor MyCommand<{ data: { name: string; description: string; }; code(): void;}>(options: { data: { name: string; description: string; }; code(): void;}): MyCommand<{ data: { name: string; description: string; }; code(): void;}>
MyCommand({ data: { name: string; description: string;}
data: { name: string
name: 'test', description: string
description: 'Just a test command' },
function code(): void
code(/* Command's params */) { /* Command's code */ }});
any
exports.any
default = new any
MyCommand({ data: { name: string; description: string;}
data: { name: string
name: 'test', description: string
description: 'Just a test command' },
function code(): void
code(/* Command's params */) { /* Command's code */ }});