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

ValidationProps interaction does not have the .reply() method #46

Closed
lassejlv opened this issue Dec 18, 2023 · 5 comments
Closed

ValidationProps interaction does not have the .reply() method #46

lassejlv opened this issue Dec 18, 2023 · 5 comments

Comments

@lassejlv
Copy link
Contributor

lassejlv commented Dec 18, 2023

https://commandkit.js.org/guide/validation-file-setup then using the ValidationProps. Then if you use interaction.reply(...) it will throw an error. Version: 0.1.10

@notunderctrl
Copy link
Member

Hi. Can you please share the exact error you're facing. Thanks

@lassejlv
Copy link
Contributor Author

When using ValidationProps type, and using .reply you are getting an type error.

@notunderctrl
Copy link
Member

I was able to reproduce the issue:

import type { ValidationProps } from 'commandkit';

export default function ({ interaction, commandObj, handler }: ValidationProps) {    
    interaction.reply('This does not work.'); // Property 'reply' does not exist on type 'ChatInputCommandInteraction<CacheType> | ContextMenuCommandInteraction<CacheType> | AutocompleteInteraction<...>'.
}

Reason

With version 1.10, validations also support autocomplete. This is a new feature in command files.

With this new update, the interaction object can now also be of type AutocompleteInteraction alongside the previous ChatInputCommandInteraction and ContextMenuCommandInteraction.

Fix

Since you can't "reply" to the AutocompleteInteraction type (you can only "respond" with autocomplete), you need to add a check in your validation to ensure that the interaction type you're handling is of either ChatInputCommandInteraction, or ContextMenuCommandInteraction.

import type { ValidationProps } from 'commandkit';

export default function ({ interaction, commandObj, handler }: ValidationProps) {
    if (interaction.isAutocomplete()) return;
    
    interaction.reply('This now works!');
}

@notunderctrl
Copy link
Member

Gonna leave this open for now for feedback

@notunderctrl notunderctrl changed the title types issue ValidationProps interaction does not have the .reply() method Dec 18, 2023
@lassejlv
Copy link
Contributor Author

Arr alright thanks for the help :) keep up the good work!

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

No branches or pull requests

2 participants