Closed OakLoaf closed 1 year ago
You can use https://discord.js.org/#/docs/discord.js/main/class/ModalSubmitInteraction?scrollTo=isFromMessage
This does not solve the issue; this only works for separating the types in to 2 categories.
The problem with what you're suggesting, is that it's impossible to safely narrow the interaction's type, so there isn't really much of a benefit here, not for TypeScript users at least.
Alternatively, you can use custom_id
and assume the source if it matches something, e.g. if a modal with a custom id of role-confirm:222197033908436994
is sent exclusively from message components, you can safely assume that a modal which custom id starts with role-confirm:
will always come from a message.
The problem with what you're suggesting, is that it's impossible to safely narrow the interaction's type, so there isn't really much of a benefit here, not for TypeScript users at least.
I don't quite understand what you mean by this?
I don't quite understand what you mean by this?
Discord does not natively send the interaction type that submitted the modal, so there is now way of actually doing that, what Kyra suggested is that you can add some type of marker
in the custom id that allows you to know where the modal came from
Additionally, this could be submitted as a feature request to Discord.
Which package is the feature request for?
discord.js
Feature
Add
.sourceType
or similarly named, which holds the type of interaction that created the form, eg. Button, ContextMenu, SlashCommand,Ideal solution or implementation
ModalSubmitInteraction#sourceType
will return the type of the interaction that triggered the modal.Alternative solutions or implementations
No response
Other context
I am unsure whether this is something that is easily implementable within the restrictions of the DiscordAPI but if it is it would be very useful.