I want to write a slash command that clears messages. Everything is fine, but there one thing I couldn’t really figure out:
How would I set the range for an integer option in a slash command build, or is there even something like this or do I need to do the old-school way and response that the value is out of range?
Here is my data for the slash command that will be registered:
data: new SlashCommandBuilder() .setName('clear') .setDescription('Clears specified amount of Messages') .addIntegerOption(option => { option .setName('amount') .setRequired(true) .setDescription('The Amount of Messages to clear') }),
Advertisement
Answer
Sadly there Is no option to set the range, but there a new thing called ephemeral that you can use as a setting in interaction.reply()
example:
interaction.reply({ content: "Your amount is bigger than 500", ephemeral: true"})
ephemeral lets only the user of the command see the reply and he can simply delete it if he wants through pressing the blue text wich says “Nachricht verferfen” in my case because my Discord is set to German.
Edit I have to correct Myself there is actually an Option for min and max for integer options and for some other options like string options you actually can write your own autocompletion