How do I force a user to specify at least one input?

I'm working on a bot, and at the moment the bot errors out if the user does not specify any argument. For reference, this is how my command is structured:
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder
.setName("about")
.setDescription(
"Find details regarding a user's account on the server list.",
)
.addUserOption((option) =>
option
.setName("by_mention")
.setDescription("User to find by mention."),
)
.addStringOption((option) =>
option
.setName("by_uuid")
.setDescription("User to find by UUID."),
)
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers),
);
}
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder
.setName("about")
.setDescription(
"Find details regarding a user's account on the server list.",
)
.addUserOption((option) =>
option
.setName("by_mention")
.setDescription("User to find by mention."),
)
.addStringOption((option) =>
option
.setName("by_uuid")
.setDescription("User to find by UUID."),
)
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers),
);
}
This is how I'm validating whether or not an argument has been specified; but strangely this kicks out an error:
const mention = interaction.options.getUser("by_mention");
const uuid = interaction.options.getString("by_uuid");

if (!mention && !uuid)
return interaction.reply({
embeds: [
embedBuilder(
this.container.client,
"You must either specify a user mention, or a UUID to find the user by.",
),
],
ephemeral: true,
});
const mention = interaction.options.getUser("by_mention");
const uuid = interaction.options.getString("by_uuid");

if (!mention && !uuid)
return interaction.reply({
embeds: [
embedBuilder(
this.container.client,
"You must either specify a user mention, or a UUID to find the user by.",
),
],
ephemeral: true,
});
How do I fix this?
Solution:
Strangely the issue doesn't appear to be occurring anymore.. will report back if it happens again.
Jump to solution
4 Replies
Cold
ColdOP6mo ago
This is the error:
[ERROR] Encountered error on chat input command "about" at path ".../dist/commands/about.js" CombinedPropertyError (1)
Received one or more errors

input[0]
| ValidationError > s.object(T)
| Expected the value to not be null
|
| Received:
| | null
[ERROR] Encountered error on chat input command "about" at path ".../dist/commands/about.js" CombinedPropertyError (1)
Received one or more errors

input[0]
| ValidationError > s.object(T)
| Expected the value to not be null
|
| Received:
| | null
Favna
Favna6mo ago
Something expects an object but gets null. Does embedBuilder possibly return it?
Cold
ColdOP6mo ago
embedBuilder simply returns a MessageEmbed, this works fine for other interaction replies
Solution
Cold
Cold6mo ago
Strangely the issue doesn't appear to be occurring anymore.. will report back if it happens again.
Want results from more Discord servers?
Add your server