Creating a command line with multiple arguments using Dsharpplus?

Asked

Viewed 40 times

1

I am starting to program in C# and as a personal project I am creating a data scrolling Discord Bot using the DSharpPlus.

My problem is how to identify arguments (I don’t know if I’m using the right term) command typed in Discord.

Examples:

/roll 6 -dif 5 -esp

When I type /roll 6 I have the return of six numbers generated by Bot. (I managed to get here)

But what I want is when you type -dif 5 for example, I would get back how many results are above or below the 5 in that case.

And in the case of -esp I need the Bot to only recognize whether or not this argument is in charge so I put it in a variable boolean. The methods and classes to get these results I’ve written, I just can’t make the connection between my code and the Bot.

This is the command I’ve written so far to execute the command /roll in Discord.

[Command("roll")]
[Aliases("r")]
public async Task Rolagem(CommandContext ctx, int dado)
{
    Dados jogada = new Dados();
    jogada.Rolagem(dado);

    var janela = new DiscordEmbedBuilder
    {
        Title = "Resultado",
        Color = DiscordColor.DarkRed,
        Description = $"Rolagem: {jogada.ExibirResultado}"                
    };

    await ctx.Channel.SendMessageAsync(embed: janela).ConfigureAwait(false);
}
  • 1

    I think in that case it might be a array of parameters, for example Rolagem(CommandContext ctx, string[] parametros)

  • I understood, but how would I make each item of the array is filled with the specific section of the command given in Discord?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.