Discord BOT检查包含特定文本的消息

时间:2017-02-27 22:20:56

标签: c# visual-studio discord discord.net

我正在尝试这样做,如果该频道有任何消息,用户名称为“@BLAH 1/3犯规语言”,则会发送消息,然后发送新消息“@BLAH 2/3犯规语言“

if (warningsChannel.Messages.ToString().Contains(e.User.Mention + " 1/3 foul language")) {
                    await warningsChannel.SendMessage(e.User.Mention + " 2/3 foul language");
                } else if(warningsChannel.Messages.ToString().Contains(e.User.Mention + " 2/3 foul language")){
                    await warningsChannel.SendMessage(e.User.Mention + " 3/3 foul language");
                } else if (warningsChannel.Messages.ToString().Contains(e.User.Mention + " 3/3 foul language")){
                   await warningsChannel.SendMessage(e.User.Mention + " has been kicked from our server for foul language.");
                    await e.User.Kick();
                }else if(warningsChannel.Messages.ToString().Contains("")){
                    await warningsChannel.SendMessage(e.User.Mention + " 1/3 foul language");
                }

1 个答案:

答案 0 :(得分:1)

使用等待warningsChannel.DownloadMessages(金额);

请注意不要下载超过100封邮件。