Skip to content

Commit

Permalink
fix: zod validation
Browse files Browse the repository at this point in the history
  • Loading branch information
xhyrom committed Feb 15, 2022
1 parent e246342 commit 7d601d2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/structures/Argument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export class Argument {
Logger.warn('The use of ArgumentOptions#options is depracted. Please use ArgumentOptions#arguments instead');
options.arguments = options.options;
}

if (this.run) options.run = this.run;

validationSchema
.parseAsync({ ...options, ...this })
.then((options) => {
Expand Down
3 changes: 3 additions & 0 deletions src/lib/structures/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export class Command {
public autoDefer?: AutoDeferType | keyof typeof AutoDeferType;

public constructor(options: CommandOptions) {
if (this.run) options.run = this.run;
if (this.onError) options.onError = this.onError;

validationSchema
.parseAsync({ ...options, ...this })
.then((options) => {
Expand Down
3 changes: 3 additions & 0 deletions src/lib/structures/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export class Component {
public autoDefer?: AutoDeferType | keyof typeof AutoDeferType;

public constructor(options: ComponentOptions) {
if (this.run) options.run = this.run;
if (this.onError) options.onError = this.onError;

validationSchema
.parseAsync({ ...options, ...this })
.then((options) => {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/structures/Listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export class Listener<
public reloading = false;

public constructor(options: ListenerOptions<WS, Event>) {
if (this.run) options.run = this.run;

validationSchema
.parseAsync({ ...options, ...this })
.then((options) => {
Expand Down

0 comments on commit 7d601d2

Please sign in to comment.