Reputation: 1361
So I usually make a new bot command with the following lines of code:
private void SayHi()
{
commands.CreateCommand("sayhi").Do(async (e) => {
await e.Channel.SendMessage("Hi");
});
}
Then the user in a channel can type "!sayhi"
and it'll print out "Hi"
. What I am trying to do using the discord.net
package in C#
is to make a dynamic command. So that the user can enter something like this: !sayhi x
where x
is whatever string the user chooses to use. And I will hopefully be able to output something like:
commands.CreateCommand("sayhi" + x).Do(async (e) => {
await e.Channel.SendMessage("Hi" + x);
});
with the output in discord looking like: "Hi x"
Upvotes: 0
Views: 3335
Reputation: 1164
Based on the documentation. You would use the Parameter method
http://rtd.discord.foxbot.me/en/legacy/features/commands.html#example-simple
commands.CreateCommand("sayhi" + x)
.Parameter("Target", ParameterType.Required)
.Do(async (e) =>
{
await e.Channel.SendMessage("Hi" + e.GetArg("Target"));
});
Upvotes: 3