C#C
C#4y ago
REAPER

Slash Command optional parameter [Answered]

Hi, I'm currently working on a poll command where I'm using SelectMenuBuilder and I want for there to be 2 required answers to create the poll. I want the rest of the answers to be optional. Is it possible to make parameters optional or will they always be required?

So far I've only been able to find the [Optional] but it only hides it when using the command, but I'm still required to enter all 8 answers to make the command work...

[SlashCommand("poll", "Create a poll where people can vote")]
        public async Task PollAsync(string Question, string answer1, string answer2, [Optional] string answer3, [Optional] string answer4, 
            [Optional] string answer5, [Optional] string answer6, [Optional] string answer7, [Optional] string answer8)
        {
            var pollBuilder = new SelectMenuBuilder()
                .WithPlaceholder("Select an option")
                .WithCustomId("menu-1")
                .WithMinValues(1)
                .WithMaxValues(1)
                .AddOption(answer1, "answer-1")
                .AddOption(answer2, "answer-2")
                .AddOption(answer3, "answer-3")
                .AddOption(answer4, "answer-4")
                .AddOption(answer5, "answer-5")
                .AddOption(answer6, "answer-6")
                .AddOption(answer7, "answer-7")
                .AddOption(answer8, "answer-8");

            var builder = new ComponentBuilder()
                .WithSelectMenu(pollBuilder);

            await RespondAsync(Question, components: builder.Build());
Was this page helpful?