2017-07-25 75 views
-1

我有這條線需要從不一致的文本通道接收消息。從不一致的聊天命令中獲取消息

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); 

} 

回答

0

包含這個功能應該從BaseModule<ICommandContext>

BaseModule派生的類包含的背景下,這在地方包含你正在尋找的信息。

Context.Message.Content