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(modals): modals, input text components and modal submits, v13 style #7431

Merged
merged 34 commits into from Apr 9, 2022

Conversation

monbrey
Copy link
Member

@monbrey monbrey commented Feb 9, 2022

Please describe the changes this PR makes and why it should be merged:
This provides support for Modals, Input Text components and Modal Submit Interactions in a semver:minor, hopefully non-breaking way for v13.

This therefore lacks improvements that have been made in the v14 and/or builders codebases, like more accurate typings for ActionRows in both messages and modals, and other such things.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)

@BehnH
Copy link

BehnH commented Feb 9, 2022

Does this not conflict with a pre-existing draft PR under #7023 ? If so, would it be worth closing the existing one if development will take place within this PR instead?

@monbrey
Copy link
Member Author

monbrey commented Feb 9, 2022

Does this not conflict with a pre-existing draft PR under #7023 ? If so, would it be worth closing the existing one if development will take place within this PR instead?

It does not, because this is for v13.

We do talk to each other internally about these things.

@monbrey monbrey changed the title v13 modals feat(modals): modals, input text components and modal submits, v13 style Feb 9, 2022
typings/enums.d.ts Outdated Show resolved Hide resolved
src/structures/InputTextComponent.js Outdated Show resolved Hide resolved
@siriscmv
Copy link

siriscmv commented Feb 9, 2022

Seems like <Message>.createMessageComponentCollector() doesn't collect model submit interactions, is this intentional?

Copy link
Contributor

@BenjammingKirby BenjammingKirby left a comment

Choose a reason for hiding this comment

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

Adding to what was already said, it's not input text, it's text input

So these should be changed as well

src/structures/TextInputComponent.js Outdated Show resolved Hide resolved
src/structures/TextInputComponent.js Outdated Show resolved Hide resolved
src/structures/TextInputComponent.js Outdated Show resolved Hide resolved
src/structures/TextInputComponent.js Outdated Show resolved Hide resolved
src/structures/Modal.js Outdated Show resolved Hide resolved
src/structures/TextInputComponent.js Outdated Show resolved Hide resolved
src/structures/TextInputComponent.js Outdated Show resolved Hide resolved
src/structures/TextInputComponent.js Outdated Show resolved Hide resolved
src/util/Constants.js Outdated Show resolved Hide resolved
src/structures/TextInputComponent.js Outdated Show resolved Hide resolved
@monbrey
Copy link
Member Author

monbrey commented Feb 9, 2022

Seems like .createMessageComponentCollector() doesn't collect model submit interactions, is this intentional?

They aren't really message components, they just happen to share the inheritance in v13. There is no message to call `createMessageComponentCollector() on because you didn't send a Message, you presented a Modal.

The InteractionCollector supports them:

const collector = new InteractionCollector(
  interaction.client, 
  { interactionType: Constants.InteractionTypes.MODAL_SUBMIT }
);

src/errors/Messages.js Show resolved Hide resolved
src/structures/ModalSubmitInteraction.js Outdated Show resolved Hide resolved
src/structures/ModalSubmitInteraction.js Outdated Show resolved Hide resolved
src/structures/TextInputComponent.js Show resolved Hide resolved
src/structures/interfaces/InteractionResponses.js Outdated Show resolved Hide resolved
src/structures/Modal.js Outdated Show resolved Hide resolved
@ghost
Copy link

ghost commented Feb 10, 2022

The Style requires a MessageButtonStyle type for some reason..
image
image

@monbrey
Copy link
Member Author

monbrey commented Feb 10, 2022

The Style requires a MessageButtonStyle type for some reason

Raw object modals arent really supported at the moment. This is a draft and shouldn't be installed. I think I know why this specifically isn't working though.

@subhanyousaf
Copy link

Looks like if you defer ModalSubmitInteraction, it throws an error when editing the reply, I am not sure if modal interactions are supposed to have deferring but here is the error when editing the reply:

G:\ModalTest\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:140
    const message = await this.webhook.editMessage('@original', options);
                                       ^

TypeError: Cannot read properties of undefined (reading 'editMessage')
    at ModalSubmitInteraction.editReply (G:\ModalTest\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:140:40)
    at Object.execute (G:\ModalTest\events\interactions.js:26:25)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

@monbrey
Copy link
Member Author

monbrey commented Feb 12, 2022

Looks like if you defer ModalSubmitInteraction, it throws an error when editing the reply, I am not sure if modal interactions are supposed to have deferring but here is the error when editing the reply

Thanks, I had made an incorrect assumption that some properties were inherited but were instead missing. Should work now.

@monbrey monbrey marked this pull request as ready for review February 12, 2022 20:53
src/util/Constants.js Outdated Show resolved Hide resolved
src/structures/BaseMessageComponent.js Show resolved Hide resolved
typings/index.d.ts Outdated Show resolved Hide resolved
@sasial-dev

This comment was marked as off-topic.

@Rohit3523

This comment was marked as off-topic.

@XboxBedrock
Copy link

Would this PR be stable enough for prod?

@thewilloftheshadow
Copy link

I've been using it on my prod bot in 1.5k servers with no problems at all

@monbrey
Copy link
Member Author

monbrey commented Apr 6, 2022

PRs are inherently unstable and I would never recommend using one in prod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet