简体   繁体   中英

How do I get message as a string varible, Discord.Net

I'm trying to maka Discord bot using Discord.Net. I wanna take message as a string variable and use it.

    [Command("GetMesage")]
    public async Task GetMssg()
    {
        await ReplyAsync("Write your message now ");
        //Message from user = string message
        await ReplyAsync(message)
    }

Instead of executing the command and then asking the user to input a message, they can provide the message at the same time the command is invoked.

    [Command("GetMesage")]
    public async Task GetMssg([Remainder] string message)
    {
        await ReplyAsync(message)
    }

This is invoked like !GetMessage Some Text here assuming a prefix of !

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM