I need help with parsing command input in my Discord bot. I want to take a single user input and break it down into two distinct parts using a delimiter like a comma or pipe symbol. For example, if someone types a command with two values separated by a comma, I want to capture the first part as one string and everything after the delimiter as another string. I’m working with Discord.Net version 0.9.6 and can’t upgrade to newer versions right now. Is there a way to achieve this parameter splitting functionality in the older version? Any code examples would be really helpful since I’m still learning how to handle command parsing properly.
Had the exact same problem when I was stuck on Discord.Net v0.9.6 for an old project. Just use string.Split() directly on the message content after you strip out your command prefix. Here’s what I did: grab the raw message text, remove your command name, then split it with your delimiter. Try string[] parts = cleanedInput.Split(new char[] { ',' }, 2); - that second parameter limits it to exactly two parts. First element is your first parameter, second element grabs everything after the first comma. Don’t forget to trim whitespace from both parts and add basic validation to make sure you got two parts before moving forward. Works great and you won’t need any fancy parsing libraries that might break with the older Discord.Net version.
you can also use indexOf() to find where the delimiter is, then substring() to split it yourself. like int splitPos = input.IndexOf(','); string first = input.Substring(0, splitPos); string second = input.Substring(splitPos + 1); just check if indexOf returns -1 first or you’ll get exceptions when there’s no comma.
I used regex for complex parsing in older Discord.Net versions - worked great. Perfect when users throw quotes around multi-word parameters or you need flexible delimiter handling. Match match = Regex.Match(input, @"^([^,]+),(.+)$"); gives you clean capture groups where match.Groups[1] and match.Groups[2] are your split parts. Handles edge cases way better than basic string operations when users input weird formatting. Just swap the comma for whatever delimiter you want. I’ve been using this since early Discord.Net days and it’s stayed solid through all the version updates.