diff --git a/docs/Commands/Command.md b/docs/Commands/Command.md index e35168dd..28291381 100644 --- a/docs/Commands/Command.md +++ b/docs/Commands/Command.md @@ -28,12 +28,9 @@ | [aliases] | Array.<String> | [] | Array of commands aliases (including the command label) | | [enabled] | Boolean | module.enabled | Whether the command is enabled | | [serverBypass] | Boolean | module.serverBypass | Whether the command can be disabled | -| [isSubcmd] | Boolean | false | Whether the command IS a subcommand | -| [parentCommand] | [Command](#Command) | | Reference to the parent command (if isSubcmd = true) | +| [parentCommand] | [Command](#Command) | | Reference to the parent command | | [hasSubcmd] | Boolean | false | Whether the command HAS subcommands | -| subcmds | Array.<Object> | | Array of subcommand objects (deleted after init) | -| [subCommands] | CommandCollection | | Collection of subcommands | -| [subCommandsAliases] | Map | | Map of subcommand aliases | +| [subCommands] | CommandRegistry | | Registry of subcommands | | info | Object | | Default info about the command | | [info.owners] | Array.<String> | | Command authors | | [info.name] | String | | Full command name | @@ -51,6 +48,8 @@ * [.template](#Command+template) : [AxonTemplate](#AxonTemplate) * [.library](#Command+library) : LibraryInterface * [.fullLabel](#Command+fullLabel) : String + * [.init()](#Command+init) ⇒ + * [._init()](#Command+_init) ⇒ Boolean * [._process(env)](#Command+_process) ⇒ Promise.<CommandContext> * [._execute(env)](#Command+_execute) ⇒ Promise.<CommandContext> * [.execute(env)](#Command+execute) ⇒ Promise.<CommandResponse> @@ -96,6 +95,16 @@ Returns the full label for this command (label + all parent labels) **Kind**: instance property of [Command](#Command) **Read only**: true + + +### command.init() ⇒ +Returns all the subcommands for a command + +**Kind**: instance method of [Command](#Command) + + +### command.\_init() ⇒ Boolean +**Kind**: instance method of [Command](#Command) ### command.\_process(env) ⇒ Promise.<CommandContext> @@ -215,11 +224,9 @@ Overrides the execute method. Execute method will be called every time the comma | [data] | Object | {} | All command parameters | | [data.label] | String | | The command label | | [data.aliases] | Array.<String> | | The command aliases | -| [data.isSubcmd] | Boolean | | Whether the command IS a subcommand | | [data.hasSubcmd] | Boolean | | Whether the command HAS subcommands | | [data.enabled] | Boolean | | Whether the command is enabled | | [data.serverBypass] | Boolean | | Whether the command can be server disabled | -| | | | | | [data.info] | Object | | | | [data.info.owners] | Array.<String> | | Who created the command | | [data.info.description] | String | | The command description | diff --git a/docs/Commands/CommandLoader.md b/docs/Commands/CommandLoader.md index 3fc13c7d..2e72cfcf 100644 --- a/docs/Commands/CommandLoader.md +++ b/docs/Commands/CommandLoader.md @@ -19,11 +19,10 @@ * [new CommandLoader(module)](#new_CommandLoader_new) * [.axon](#CommandLoader+axon) : AxonClient * [.logger](#CommandLoader+logger) : Logger - * [.load(command, [parent])](#CommandLoader+load) ⇒ Boolean + * [.load(command, parent)](#CommandLoader+load) ⇒ Boolean * [.loadAll(commands)](#CommandLoader+loadAll) ⇒ Boolean * [.unload(label)](#CommandLoader+unload) ⇒ Boolean - * [.registerCommand(command)](#CommandLoader+registerCommand) - * [.registerSubCommand(command, parent)](#CommandLoader+registerSubCommand) + * [.registerCommand(command, registry)](#CommandLoader+registerCommand) * [.unregisterCommand(fullLabel)](#CommandLoader+unregisterCommand) ⇒ Boolean * [.unregisterSubCommand(command, subCommand)](#CommandLoader+unregisterSubCommand) @@ -59,28 +58,28 @@ Returns the Logger instance **Read only**: true -### commandLoader.load(command, [parent]) ⇒ Boolean +### commandLoader.load(command, parent) ⇒ Boolean Load one command instance in the module. Validate and correct the command before registering it. **Kind**: instance method of [CommandLoader](#CommandLoader) -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| command | Command | | The command to load | -| [parent] | Command | | The optional parent command | +| Param | Type | Description | +| --- | --- | --- | +| command | Command | The command to load | +| parent | CommandRegistry | The registry to load the command into | ### commandLoader.loadAll(commands) ⇒ Boolean -Load all commands in the module. +Load all non instantiated commands in the module. Instantiate all commands. **Kind**: instance method of [CommandLoader](#CommandLoader) -| Param | Type | -| --- | --- | -| commands | Object.<string, Command> | +| Param | Type | Description | +| --- | --- | --- | +| commands | Object.<string, Command> | Non instantiated Commands | @@ -96,7 +95,7 @@ Unload a Command from the client -### commandLoader.registerCommand(command) +### commandLoader.registerCommand(command, registry) Register a Command. Register its subcommands if it has any. **Kind**: instance method of [CommandLoader](#CommandLoader) @@ -104,18 +103,7 @@ Register a Command. Register its subcommands if it has any. | Param | Type | Description | | --- | --- | --- | | command | Command | Command object | - - - -### commandLoader.registerSubCommand(command, parent) -Register a SubCommand.Register its subcommands if it has any - -**Kind**: instance method of [CommandLoader](#CommandLoader) - -| Param | Type | Description | -| --- | --- | --- | -| command | Command | The subcommand to register | -| parent | Command | The parent command | +| registry | CommandRegistry | The registry to register the command into | @@ -151,11 +139,10 @@ Remove a subcommand from a command * [new CommandLoader(module)](#new_CommandLoader_new) * [.axon](#CommandLoader+axon) : AxonClient * [.logger](#CommandLoader+logger) : Logger - * [.load(command, [parent])](#CommandLoader+load) ⇒ Boolean + * [.load(command, parent)](#CommandLoader+load) ⇒ Boolean * [.loadAll(commands)](#CommandLoader+loadAll) ⇒ Boolean * [.unload(label)](#CommandLoader+unload) ⇒ Boolean - * [.registerCommand(command)](#CommandLoader+registerCommand) - * [.registerSubCommand(command, parent)](#CommandLoader+registerSubCommand) + * [.registerCommand(command, registry)](#CommandLoader+registerCommand) * [.unregisterCommand(fullLabel)](#CommandLoader+unregisterCommand) ⇒ Boolean * [.unregisterSubCommand(command, subCommand)](#CommandLoader+unregisterSubCommand) @@ -191,28 +178,28 @@ Returns the Logger instance **Read only**: true -### commandLoader.load(command, [parent]) ⇒ Boolean +### commandLoader.load(command, parent) ⇒ Boolean Load one command instance in the module. Validate and correct the command before registering it. **Kind**: instance method of [CommandLoader](#CommandLoader) -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| command | Command | | The command to load | -| [parent] | Command | | The optional parent command | +| Param | Type | Description | +| --- | --- | --- | +| command | Command | The command to load | +| parent | CommandRegistry | The registry to load the command into | ### commandLoader.loadAll(commands) ⇒ Boolean -Load all commands in the module. +Load all non instantiated commands in the module. Instantiate all commands. **Kind**: instance method of [CommandLoader](#CommandLoader) -| Param | Type | -| --- | --- | -| commands | Object.<string, Command> | +| Param | Type | Description | +| --- | --- | --- | +| commands | Object.<string, Command> | Non instantiated Commands | @@ -228,7 +215,7 @@ Unload a Command from the client -### commandLoader.registerCommand(command) +### commandLoader.registerCommand(command, registry) Register a Command. Register its subcommands if it has any. **Kind**: instance method of [CommandLoader](#CommandLoader) @@ -236,18 +223,7 @@ Register a Command. Register its subcommands if it has any. | Param | Type | Description | | --- | --- | --- | | command | Command | Command object | - - - -### commandLoader.registerSubCommand(command, parent) -Register a SubCommand.Register its subcommands if it has any - -**Kind**: instance method of [CommandLoader](#CommandLoader) - -| Param | Type | Description | -| --- | --- | --- | -| command | Command | The subcommand to register | -| parent | Command | The parent command | +| registry | CommandRegistry | The registry to register the command into | diff --git a/docs/Core/Base.md b/docs/Core/Base.md index 957c0002..78c275d8 100644 --- a/docs/Core/Base.md +++ b/docs/Core/Base.md @@ -8,7 +8,7 @@ ## Typedefs
-
Ctx : Object
+
AllowedMentions : Object
@@ -138,7 +138,7 @@ Reject promise if not | user | User | | User object to get the DM channel | | content | String \| MessageObject | | String or object (embed) | | [options] | Object | {} | Options { disableEveryone: Boolean, delete: Boolean, delay: Number } | -| [options.disableEveryone] | Boolean | true | Whether to allow mentioning everyone or not | +| [options.allowedMentions] | [AllowedMentions](#AllowedMentions) | | Custom allowed mentions object | | [options.delete] | Boolean | false | Whether to delete the message or not | | [options.delay] | Number | | Delay after which the message will be deleted | @@ -157,7 +157,7 @@ Doesn't support file | channel | Channel | | The channel Object | | content | String \| MessageObject | | Message content, String or Embed Object | | [options] | Object | {} | Options { disableEveryone: Boolean, delete: Boolean, delay: Number } | -| [options.disableEveryone] | Boolean | true | Whether to allow mentioning everyone or not | +| [options.allowedMentions] | [AllowedMentions](#AllowedMentions) | | Custom allowed mentions object | | [options.delete] | Boolean | false | Whether to delete the message or not | | [options.delay] | Number | | Delay after which the message will be deleted | @@ -190,7 +190,7 @@ Await for sendMessage to throw correctly potential errors. | channel | Channel | | The channel Object | | content | String \| MessageObject | | Success message content | | [options] | Object | {} | Additional options | -| [options.disableEveryone] | Boolean | true | Whether to allow mentioning everyone or not | +| [options.allowedMentions] | [AllowedMentions](#AllowedMentions) | | Custom allowed mentions object | | [options.delete] | Boolean | false | Whether to delete the message or not | | [options.delay] | Number | | Delay after which the message will be deleted | | [options.triggerCooldown] | Boolean | true | Whether the command should trigger cooldown or not | @@ -210,7 +210,7 @@ Await for sendMessage to throw correctly potential errors. | channel | Channel | | The channel Object | | content | String \| MessageObject | | Success message content | | [options] | Object | {} | Additional options | -| [options.disableEveryone] | Boolean | true | Whether to allow mentioning everyone or not | +| [options.allowedMentions] | [AllowedMentions](#AllowedMentions) | | Custom allowed mentions object | | [options.delete] | Boolean | false | Whether to delete the message or not | | [options.delay] | Number | | Delay after which the message will be deleted | | [options.triggerCooldown] | Boolean | false | Whether the command should trigger cooldown or not | @@ -260,7 +260,7 @@ Creates an instance of Base. | --- | --- | | axonClient | AxonClient | - + -## Ctx : Object +## AllowedMentions : Object **Kind**: global typedef diff --git a/docs/README.md b/docs/README.md index 1d78ba23..6b9a3618 100644 --- a/docs/README.md +++ b/docs/README.md @@ -57,6 +57,7 @@ AxonCore is lib agnostic, which mean you can use it indifferently with [Eris](ht - **Translations** - Built-in support for translation and message management system. - **Logging** - Built-in custom logging. - **Tracking** - Easily track and debug command usage, events and errors with custom events emitted by AxonCore. +- **Typescript support** - Full typescript and intellisense support ## Philosophy @@ -78,6 +79,10 @@ Here's how to use it: - Available libraries: `eris`, `discordjs`. - Available module types: `commonjs`, `esm`. +AxonCore has **FULL** typescript support. +When you install the package the first time, you can choose the library you are using, and the package will automatically link the library typings. That will allow you to have full and complete typings for your typescript project or for using intllisense. +Note: AxonCore creates a `.axoncorerc` file with the default configuration. Editing or deleting this file will change the typings link on the next install. + ## Features Overview Because it is built with the correct level abstraction, using AxonCore feels natural and powerful. Everything is easily accessible, extendable and customisable. @@ -159,13 +164,17 @@ axonClient.on('listenerError', (eventName: String, listenerName: String, { liste ### Utilities - [Embed](src/Utility/External/Embed.js) -- Resolver +- [Resolver](src/Libraries/definitions/Resolver.js) - [Utility](src/Utility/Utils.js) -- Message Collector [TODO-outdated] +- [Collectors](src/Utility/Discord/Collectors/Collector.js) +- [Message Collector](src/Utility/Discord/Collectors/MessageCollector.js) - Reaction collector [TODO-outdated] - [LRUCache](src/Utility/External/LRUCache.js) +- [SortedList](src/Utility/External/SortedList.js) +- [Stack](src/Utility/External/Stack.js) - [Queue](src/Utility/External/Queue.js) +- [FunctionQueue](src/Utility/External/FunctionQueue.js) - [AsyncQueue](src/Utility/External/AsyncQueue.js) - [AutoQueue](src/Utility/External/AutoQueue.js) diff --git a/docs/Utility/AxonUtils.md b/docs/Utility/AxonUtils.md index 97b7951d..6b811b48 100644 --- a/docs/Utility/AxonUtils.md +++ b/docs/Utility/AxonUtils.md @@ -8,7 +8,7 @@ ## Typedefs
-
AxonTemplate : Object
+
AllowedMentions : Object
@@ -29,7 +29,7 @@ * _instance_ * [.axon](#AxonUtils+axon) : AxonClient * [.bot](#AxonUtils+bot) : BotClient - * [.template](#AxonUtils+template) : [AxonTemplate](#AxonTemplate) + * [.template](#AxonUtils+template) : AxonTemplate * [.logger](#AxonUtils+logger) : ALogger * [.utils](#AxonUtils+utils) : Utils * [.library](#AxonUtils+library) : LibraryInterface @@ -71,7 +71,7 @@ Returns the BotClient instance **Read only**: true -### axonUtils.template : [AxonTemplate](#AxonTemplate) +### axonUtils.template : AxonTemplate Returns the template object **Kind**: instance property of [AxonUtils](#AxonUtils) @@ -210,7 +210,7 @@ Reject promise if not | user | User | | User object to get the DM channel | | content | String \| MessageObject | | String or object (embed) | | [options] | Object | {} | Options { disableEveryone: Boolean, delete: Boolean, delay: Number } | -| [options.disableEveryone] | Boolean | true | Whether to allow mentioning everyone or not | +| [options.allowedMentions] | [AllowedMentions](#AllowedMentions) | | Custom allowed mentions object | | [options.delete] | Boolean | false | Whether to delete the message or not | | [options.delay] | Number | | Delay after which the message will be deleted | @@ -229,7 +229,7 @@ Doesn't support file uploads. | channel | Channel | | The channel Object | | content | String \| MessageObject | | Message content: String or Embed Object | | [options] | Object | {} | Options { disableEveryone: Boolean, delete: Boolean, delay: Number } | -| [options.disableEveryone] | Boolean | true | Whether to allow mentioning everyone or not | +| [options.allowedMentions] | [AllowedMentions](#AllowedMentions) | | Custom allowed mentions object | | [options.delete] | Boolean | false | Whether to delete the message or not | | [options.delay] | Number | | Delay after which the message will be deleted | @@ -261,7 +261,7 @@ Creates an AxonUtils instance. | --- | --- | | axon | AxonClient | - + -## AxonTemplate : Object +## AllowedMentions : Object **Kind**: global typedef diff --git a/docs/Utility/Utils.md b/docs/Utility/Utils.md index af580267..3a4967e0 100644 --- a/docs/Utility/Utils.md +++ b/docs/Utility/Utils.md @@ -45,6 +45,7 @@ * [.hasPerms(member, permissions)](#Utils+hasPerms) ⇒ Boolean * [.hasChannelPerms(channel, permissions, [user])](#Utils+hasChannelPerms) ⇒ Boolean * [.missingPerms(member, [permissions])](#Utils+missingPerms) ⇒ Array.<String> + * [.missingChannelPerms(channel, member, [permissions])](#Utils+missingChannelPerms) ⇒ Array.<String> * [.calculatePerms(data)](#Utils+calculatePerms) ⇒ Object * [.sleep(ms)](#Utils+sleep) ⇒ Promise.<void> * [.readFileAsync(path)](#Utils+readFileAsync) ⇒ Promise.<String> @@ -214,6 +215,20 @@ List all missing permissions of the given user. | member | Member | | | | [permissions] | Array.<String> | [] | List of permissions to test | + + +### utils.missingChannelPerms(channel, member, [permissions]) ⇒ Array.<String> +List all missing permissions of the given user in the given channel. + +**Kind**: instance method of [Utils](#Utils) +**Returns**: Array.<String> - An array of missing permissions + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| channel | Channel | | | +| member | Member | | | +| [permissions] | Array.<String> | [] | List of permissions to test | + ### utils.calculatePerms(data) ⇒ Object