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

Allow InteractionOptionResolvers to return the raw value for different option types (like user) #10344

Open
vladfrangu opened this issue Jun 10, 2024 · 4 comments

Comments

@vladfrangu
Copy link
Member

Which application or package is this feature request for?

discord.js

Feature

Messing around with autocomplete interactions, I've found out that we don't have a nicer way of getting the raw id provided in a previous option when autocompleting outside of doing interaction.options.get(). Unfortunately, we also cannot provide the full methods because Discord doesn't send us resolved data in this interaction type, only the ids.

Ideal solution or implementation

Ideally, we'd provide shortcuts for getting those ids, something like getUserValue or some much better name than what I came up with on the spot!

Alternative solutions or implementations

No response

Other context

new SlashCommandBuilder()
	.setName('example')
	.setDescription('example')
	.addUserOption((user) =>
		user.setName('user').setDescription('The user to filter autocomplete by').setRequired(true),
	)
	.addStringOption((id) =>
		id
			.setName('autofill-me')
			.setDescription('Value that gets autofilled with data dependent on whatever user has, or nothing is user is not set')
			.setRequired(true)
			.setAutocomplete(true),
	);
@Jiralite
Copy link
Member

What about making the second parameter of all these methods an object that has a raw option (and required, of course) to return the payload from the API?

@Qjuh
Copy link
Contributor

Qjuh commented Jun 11, 2024

Isn’t that what <AutocompleteInteraction>.options.get(…) already gives you?

@Jiralite Jiralite removed the chore label Jun 11, 2024
@Jiralite
Copy link
Member

Yeah... from reading the feature request, using that method is not desired. Unless I'm reading it wrong.

@monbrey
Copy link
Member

monbrey commented Jun 11, 2024

Is this just so the raw value can be correctly typed between string, number and boolean? There's otherwise no benefit to it being a "getUserValue" method as all Snowflakes are strings.

The regular number and boolean methods would work without needing this.

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

No branches or pull requests

4 participants