Home > database >  Can I use a List<string> as Choice Parameters for a Slash Command?
Can I use a List<string> as Choice Parameters for a Slash Command?

Time:10-17

Reading the documentation of Discord.Net, I found that I can use an Enum as parameter of my module to allow my users to pick a value from the enum when they type a slash command :

public class CharacterChoiceModule : InteractionModuleBase<SocketInteractionContext>
{
    [SlashCommand("personnage", "test")]
    public async Task Choice(PersonnageName personnage)
    {
        ...
    }
}

public enum PersonnageName
{
    Gérard,
    Daniel
}

It results as a pickable PersonnageName that I can use in my code with the variable personnage passed as parameter. The Ui of the choice is the following : enter image description here

But now I want to pass a dynamic list of choices, for example a List<string> that I could populate through a database.

Is it possible to use a dynamic List as Choice Parameters for a Slash Command ?

CodePudding user response:

No. All choices must be declared when you register the slash command. This is a limitation of the Discord API, not the C# library.

  • Related