Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: stricter types for preconditions #226

Merged
merged 1 commit into from
Jul 15, 2021

Conversation

kyranet
Copy link
Member

@kyranet kyranet commented Jul 13, 2021

  • Added Command#parseConstructorPreConditions.
  • Added Command#parseConstructorPreConditionsRunIn.
  • Added Command#parseConstructorPreConditionsNsfw.
  • Added Command#parseConstructorPreConditionsRequiredClientPermissions.
  • Added Command#parseConstructorPreConditionsCooldown.
  • Added CommandPreConditions.Permissions.
  • Added CommandOptions.cooldownScope.
  • Added CommandOptions.requiredClientPermissions.
  • Added Preconditions interface, this strict types all precondition names and contexts.
  • Added PreconditionContainerArray#append.
  • Added SimplePreconditionSingleResolvableDetails.
  • Fixed cooldown precondition not working when defining alias properties from Command.
  • ⚠️ BREAKING CHANGE: Changed Command#preconditions to PreconditionContainerArray.
  • ⚠️ BREAKING CHANGE: Removed Command#resolveConstructorPreConditions.
  • ⚠️ BREAKING CHANGE: Renamed CommandOptions.cooldownBucket to cooldownLimit.
  • ⚠️ BREAKING CHANGE: Renamed CommandOptions.cooldownDuration to cooldownDelay.
  • ⚠️ BREAKING CHANGE: Renamed BucketType to BucketScope.
  • ⚠️ BREAKING CHANGE: Changed PreconditionSingleResolvableDetails to take a type parameter.
  • ⚠️ BREAKING CHANGE: Changed PreconditionSingleResolvable to use Preconditions's type.
  • ⚠️ BREAKING CHANGE: Renamed CooldownContext.bucketType to scope.

@kyranet kyranet requested a review from favna as a code owner July 13, 2021 18:27
@kyranet kyranet requested a review from vladfrangu July 13, 2021 18:27
@kyranet kyranet force-pushed the refactor/strict-type-preconditions branch from d0e9f99 to 1e3f9c2 Compare July 13, 2021 19:34
vladfrangu
vladfrangu previously approved these changes Jul 13, 2021
* @since 2.0.0
* @param options The command options given from the constructor.
*/
protected parseConstructorPreConditions(options: CommandOptions): void {
Copy link
Member

@favna favna Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be sure to mention this in discordjs/guide#711 because otherwise people won't know they have to extend this to have their own custom preconditions with a constructor pattern.

src/lib/structures/Precondition.ts Outdated Show resolved Hide resolved
src/lib/structures/Precondition.ts Outdated Show resolved Hide resolved
src/lib/structures/Precondition.ts Outdated Show resolved Hide resolved
Copy link
Member

@favna favna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoever ends up hitting merge be sure to add a whiteline before the breaking changes:

So:

Fixed cooldown precondition not working when defining alias properties from `Command`.
BREAKING CHANGE: Changed `Command#preconditions` to `PreconditionContainerArray`.

Becomes:

Fixed cooldown precondition not working when defining alias properties from `Command`.

BREAKING CHANGE: Changed `Command#preconditions` to `PreconditionContainerArray`.

Added `Command#parseConstructorPreConditions`.
Added `Command#parseConstructorPreConditionsRunIn`.
Added `Command#parseConstructorPreConditionsNsfw`.
Added `Command#parseConstructorPreConditionsRequiredClientPermissions`.
Added `Command#parseConstructorPreConditionsCooldown`.
Added `CommandPreConditions.Permissions`.
Added `CommandOptions.cooldownScope`.
Added `CommandOptions.requiredClientPermissions`.
Added `Preconditions` interface, this strict types all precondition names and contexts.
Added `PreconditionContainerArray#append`.
Added `SimplePreconditionSingleResolvableDetails`.
Fixed cooldown precondition not working when defining alias properties from `Command`.

BREAKING CHANGE: Changed `Command#preconditions` to `PreconditionContainerArray`.
BREAKING CHANGE: Removed `Command#resolveConstructorPreConditions`.
BREAKING CHANGE: Renamed `CommandOptions.cooldownBucket` to `cooldownLimit`.
BREAKING CHANGE: Renamed `CommandOptions.cooldownDuration` to `cooldownDelay`.
BREAKING CHANGE: Renamed `BucketType` to `BucketScope`.
BREAKING CHANGE: Changed `PreconditionSingleResolvableDetails` to take a type parameter.
BREAKING CHANGE: Changed `PreconditionSingleResolvable` to use `Preconditions`'s type.
BREAKING CHANGE: Renamed `CooldownContext.bucketType` to `scope`.
@kyranet kyranet force-pushed the refactor/strict-type-preconditions branch from 1e3f9c2 to 0462736 Compare July 15, 2021 08:41
@kyranet kyranet requested review from favna and vladfrangu July 15, 2021 08:41
@kyranet
Copy link
Member Author

kyranet commented Jul 15, 2021

I force-pushed with a fixed description (and resolved requests), so the separation isn't needed, @favna

@favna favna changed the title refactor: strict type preconditions feat: stricter types for preconditions Jul 15, 2021
@favna favna merged commit 4a3c76a into main Jul 15, 2021
@favna favna deleted the refactor/strict-type-preconditions branch July 15, 2021 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants