How to make a Discord bot command accept multiple words as input?

Hey everyone! I’m working on a Discord bot and I’m stuck. I want to create a command that takes in a whole sentence as input, but it’s only grabbing the first word. Here’s what I’ve got so far:

commands.CreateCommand("funnyText")
    .Parameter("message", ParameterType.Multiple)
    .Do(async (e) =>
    {
        string userMessage = e.GetArg("message");
        string alteredMessage = AlterText(userMessage);
        await e.Channel.SendMessage(alteredMessage);
    });

When I try to use it like this:
$funnyText Hello world, how are you?

The bot only picks up “Hello”. Any ideas on how to make it grab the whole input? I’m trying to make a fun command that changes the text style, kinda like those meme generators. Thanks for any help!

hey dude, i think i kno what’s goin on. try using ParameterType.Unparsed instead of Multiple. that should grab everything after the command as one big chunk. lemme know if that works for ya!

Hey there, ExcitedGamer85! I’ve dealt with this exact problem before while making my own Discord bot. The issue is that ParameterType.Multiple doesn’t quite do what you’re expecting. Instead, try using ParameterType.Unparsed. This will grab everything after your command as a single string.

Here’s how you can tweak your code:

commands.CreateCommand("funnyText")
    .Parameter("message", ParameterType.Unparsed)
    .Do(async (e) =>
    {
        string userMessage = e.GetArg("message");
        string alteredMessage = AlterText(userMessage);
        await e.Channel.SendMessage(alteredMessage);
    });

This should work like a charm for your meme generator idea. Now when someone types ‘$funnyText Hello world, how are you?’, your bot will capture the entire message. Just make sure your AlterText function can handle the full string input.

Let me know if you run into any other issues. Good luck with your bot!

I’ve run into this issue before. The trick is to use ParameterType.Unparsed instead of ParameterType.Multiple. This tells the command to treat everything after the command name as a single argument. Here’s how you can modify your code:

commands.CreateCommand("funnyText")
    .Parameter("message", ParameterType.Unparsed)
    .Do(async (e) =>
    {
        string userMessage = e.GetArg("message");
        string alteredMessage = AlterText(userMessage);
        await e.Channel.SendMessage(alteredMessage);
    });

This should capture the entire input after $funnyText. Just make sure your AlterText function can handle the full string input. Hope this helps!