Skip to content

Latest commit

 

History

History
82 lines (79 loc) · 6.03 KB

4.0.0-changes.md

File metadata and controls

82 lines (79 loc) · 6.03 KB

This version includes many breaking changes and a full internal rewrite.

  • Patron's name on NPM has changed! We were able to get the patron module on NPM, all future versions of patron will be released on it.
  • Patron is now licensed under LGPL-3.0. This is a far more lax license that should allow more freedom to patron users.
  • Patron now automatically detects the Discord wrapper library used when possible. If only one wrapper library is installed, patron will detect and use that. Otherwise, you can swap between libraries at any point using the static Registry#setLibrary() method.
  • Patron supports ECMAScript modules. You can simply use import in any ECMAScript modules (includes named exports). Patron still maintains full support of CommonJS modules.
  • Patron has full TypeScript support. Although patron had typings already, they were untested and poorly written. The typings are now highly tested and have been checked over by several TypeScript developers (Thank you George, Apacheli and Skillz4Killz).

List of all changes:

  • Changed all enums to use Numbers instead of Symbols. This was done to improve TypeScript support.
  • Renamed CommandError to ResultType:
    • Renamed BotPermission to ClientPermission.
    • Renamed Command to Execution.
    • Renamed Exception to Error.
    • Renamed InvalidArgCount to ArgumentCount.
    • Renamed InvalidContext to Context.
    • Renamed UnknownCmd to Unknown.
  • Added ResultType.Success, which replaces Result.success.
  • Added ResultType.ArgumentOrder, which indicates out-of-order chained optional Arguments.
  • Changed several default TypeReaders:
    • BooleanReader accepts more inputs, including "on" and "off".
    • ColorReader only accepts hex colors.
    • IntegerReader doesn't accept unsafe integers.
    • TimeReader:
      • Doesn't accept excessively large or negative numbers.
      • No longer considers centuries or decades valid units of time.
      • Will parse valid unit names without any number as one of that unit.
    • Removed all Channel-related readers except for GuildChannelReader.
    • Renamed GuildChannelReader to ChannelReader.
    • Removed GuildEmojiReader, equivalent behavior can be achieved with a Precondition and the EmojiReader.
  • Changed Result:
    • Removed Result.errorReason.
    • Removed Result.commandName.
    • Removed Result.success (see ResultType.Success).
    • Renamed Result.commandError to Result.type.
  • Removed ArgumentResult.
  • CommandResult now handles unknown commands, invalid argument counts, and out-of-order arguments.
  • ExecutionResult now handles the original functionality of the CommandResult class.
    • Added ExecutionResult.fromSuccess(), which provides a value to Postconditions without reverting Cooldowns like fromFailure() does.
  • Added CooldownResult.group, which will be true if the Cooldowns were on a Group and not a Command.
  • Renamed ExceptionResult to ErrorResult.
  • Renamed InvalidContextResult to ContextResult.
  • Removed description from every structure except for Command and Group, it now defaults to undefined.
  • Changed Argument:
    • Changed name and key to default to the value of type.
    • Added typeOptions which provides custom options to the TypeReader.
    • Significantly improved the functionality of optional arguments.
  • ArgumentPrecondition and Precondition no longer require run() to return a Promise.
  • The value/input parameters of ArgumentPrecondition.run()/TypeReader.read() are now first.
  • Added Command.setDefaults() and Group.setDefaults() methods which set default options for the structures.
  • Changed Command:
    • arguments accepts ArgumentOptions as well as Arguments.
    • Renamed botPermissions to clientPermissions.
    • Changed group to be optional.
    • Removed hasCooldown, check if cooldowns is defined instead.
    • Changed cooldowns to be an array instead of a single cooldown.
    • getExample() and getUsage() have an optional prefix parameter.
    • getExample() returns undefined if any Argument examples are missing.
    • Renamed all cooldown methods (e.g. useCooldown) to have plural names.
  • Changed Group:
    • Added cooldowns, which will be an array of Cooldowns to run on every Command in the group.
    • Added cooldown methods which are identical to the ones Commands have.
    • Removed commands, use Registry.getGroupedCommands() instead.
  • Changed Cooldown:
    • Added aggressive, when enabled the cooldown will be set back to the full duration every time it's used past the limit.
    • Changed sorter, now async functions can be provided and a Message object is supplied instead of user and guild IDs.
    • Added failure, which indicates that a Cooldown should be applied to failed Command executions only.
  • Changed Postcondition.run()'s second parameter from a result to a value provided by an ExecutionResult, and added a Command parameter at the start.
  • Changed Registry:
    • Added static setLibrary() method for simpler usage and set up automatic detection.
    • Stores all structures in Maps instead of Arrays.
    • Added get() methods for all structures (e.g. getCommand()).
    • Added registerPrefixes() and unregisterPrefixes() for full prefix support. Global prefixes will apply to DMs and all guilds with no guild-specific prefixes.
  • Changed Handler:
    • Undocumented all methods except for run() and runPreconditions(), other methods have no guarantees.
    • Removed the prefixLength parameter from run() (see Registry.registerPrefixes()).
    • Added executeCommand() for manual execution of Commands.
    • Added parsePrefix() for determining which prefix a message has.
  • Changed Mutex to use lock() and unlock() instead of sync().
  • Removed MultiMutex from exports, use cases were too rare and identical functionality can be achieved with Mutex.
  • Added ImportAll, which will replace RequireAll when the library is used in an ECMAScript module.