C# 从discord聊天中获取命令中的消息

C# 从discord聊天中获取命令中的消息,c#,discord,discord.net,C#,Discord,Discord.net,我有一行需要接收来自discord文本频道的消息 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("Th

我有一行需要接收来自discord文本频道的消息

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

}
[命令(“join”,RunMode=RunMode.Async),摘要(“joins voice channel”)]
公共异步任务joinvoice([余数,摘要(“要回显的文本”)]字符串searchP=”“)
{
IVoiceChannel voicechannel=(CommandHandler.Last作为IGuildUser)。voicechannel;
如果(语音通道==null)
{
等待回复同步(“你必须先进入频道”);
返回;
}
字符串选择=”;
VideoSearchrisolts=新的VideoSearch();
如果(searchP!=“”)
{
if(searchP.Contains(“https:/”)
选择=搜索;
其他的
{
List video=SearchRisolts.SearchQuery(searchP,1);
等待回复同步(“1)”+视频[0]。标题+“\n\n2)”+视频[1]。标题+“\n\n3)”+视频[2]。标题);
choice=video[int.Parse(CommandHandler.message.Content)-1].Url;//这里我需要接收来自聊天室的消息
}
}
if(voicechannel!=程序.voicechannel)
{
Program.audioClient=等待voicechannel.ConnectAsync();
Program.voicechannel=语音频道;
}
if(Program.audioClient!=null)
等待SendAsync(Program.audioClient,选项);
}

包含此函数的类应派生自
BaseModule

此BaseModule包含上下文,其中包含您正在查找的消息

Context.Message.Content