I'm trying to code a Discord bot but my C# is a bit rusty at the moment. I'm trying to make it so someone can send an alert to the admin console by doing a command in a channel.
The commands work by doing -conalert (the message) but, at the moment it only works if it's a one-word message.
I remember using this function for a similar project that I since have lost and it worked like a charm.
[Command("conalert")]
public async Task conalert(string msg)
{
EmbedBuilder conalert = new EmbedBuilder();
Console.WriteLine(msg);
}
Thanks.
You should add the [Remainder]
attribute:
public async Task conalert([Remainder]string msg)
A more complete interesting example is here: https://www.gngrninja.com/code/2019/4/1/c-discord-bot-command-handling
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.