Reputation: 21
I have finally successfully updated to discord.NET 1.0 and I'm trying to do a simple echo command, I don't know how to get the message as a string though, any help?
[Command("say")]
private async Task echo()
{
string input = message
context.Channel.SendMessageAsync(input);
}
Upvotes: 1
Views: 8030
Reputation: 799
It's the same as passing arguments into a function, here is an example :
[Command("say")]
private async Task echo(string text)
{
context.Channel.SendMessageAsync(text);
}
If you would like to get an argument with spaces, you add the [Remainder]
attribute :
[Command("say")]
private async Task echo([Remainder]string text)
{
context.Channel.SendMessageAsync(text);
}
Note : Any argument with this attribute has to be last, like an optional argument.
Upvotes: 3
Reputation: 458
You would need to add an argument.
[Command("say")]
private async Task echo([Remainder]string text)
{
context.Channel.SendMessageAsync(text);
}
Upvotes: 0