Skip to content

Commit

Permalink
feat: add success property in command finished payload (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-priyam committed Jun 30, 2022
1 parent cfb3547 commit 8198e94
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/lib/types/Events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ export interface MessageCommandRunPayload extends MessageCommandAcceptedPayload
}

export interface MessageCommandFinishPayload extends MessageCommandRunPayload {
success: boolean;
duration: number;
}

Expand Down Expand Up @@ -455,6 +456,7 @@ export interface ChatInputCommandAcceptedPayload extends PreChatInputCommandRunP
export interface ChatInputCommandRunPayload extends ChatInputCommandAcceptedPayload {}

export interface ChatInputCommandFinishPayload extends ChatInputCommandAcceptedPayload {
success: boolean;
duration: number;
}

Expand Down Expand Up @@ -496,6 +498,7 @@ export interface ContextMenuCommandAcceptedPayload extends PreContextMenuCommand
export interface ContextMenuCommandRunPayload extends ContextMenuCommandAcceptedPayload {}

export interface ContextMenuCommandFinishPayload extends ContextMenuCommandAcceptedPayload {
success: boolean;
duration: number;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export class CoreListener extends Listener<typeof Events.ChatInputCommandAccepte
this.container.client.emit(Events.ChatInputCommandError, result.error, { ...payload, duration: result.value ?? -1 });
}

this.container.client.emit(Events.ChatInputCommandFinish, interaction, command, { ...payload, duration: result.value ?? -1 });
this.container.client.emit(Events.ChatInputCommandFinish, interaction, command, {
...payload,
success: !isErr(result),
duration: result.value ?? -1
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export class CoreListener extends Listener<typeof Events.ContextMenuCommandAccep
this.container.client.emit(Events.ContextMenuCommandError, result.error, { ...payload, duration: result.value ?? -1 });
}

this.container.client.emit(Events.ContextMenuCommandFinish, interaction, command, { ...payload, duration: result.value ?? -1 });
this.container.client.emit(Events.ContextMenuCommandFinish, interaction, command, {
...payload,
success: !isErr(result),
duration: result.value ?? -1
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export class CoreListener extends Listener<typeof Events.MessageCommandAccepted>
message.client.emit(Events.MessageCommandError, result.error, { ...payload, args, duration: result.value ?? -1 });
}

message.client.emit(Events.MessageCommandFinish, message, command, { ...payload, args, duration: result.value ?? -1 });
message.client.emit(Events.MessageCommandFinish, message, command, {
...payload,
args,
success: !isErr(result),
duration: result.value ?? -1
});
}
}

0 comments on commit 8198e94

Please sign in to comment.