从不和谐聊天中获取命令中的消息

我有这条线需要收到来自不和谐文本 Channels 的消息 .

choice = video[int.Parse(CommandHandler.message .Content)-1].Url;

我尝试了很多东西,包括在api中搜索,但我没有线索 .

这是命令

[Command("join", RunMode= RunMode.Async), Summary("joins voice channel")]
public async Task joinvoice([Remainder, Summary("The text to echo")] string searchP="")
{

    IVoiceChannel voicechannel = (CommandHandler.Last as IGuildUser).VoiceChannel;

    if (voicechannel == null)
    {
        await ReplyAsync("u have to be in a channel first");
        return;

    }
    string choice = "";
    VideoSearch SearchRisolts = new VideoSearch();
    if (searchP != "")
    {
        if (searchP.Contains("https://"))
            choice = searchP;
        else
        {
            List<VideoInformation> video = SearchRisolts.SearchQuery(searchP, 1);
            await ReplyAsync("1) " + video[0].Title + "\n\n2) " + video[1].Title + "\n\n3) " + video[2].Title);

            choice = video[int.Parse(CommandHandler.message .Content)-1].Url;//here i need to recive a message from the chat
        }
    }

    if (voicechannel != Program.voicechannel)
    {
        Program.audioClient = await voicechannel.ConnectAsync();
        Program.voicechannel = voicechannel;

    }
    if (Program.audioClient!=null)
        await SendAsync(Program.audioClient, choice);

}

回答(1)

2 years ago

包含此函数的类应该派生自 BaseModule<ICommandContext>

此BaseModule包含Context,它包含您正在查找的消息 .

Context.Message.Content