有没有办法让Discord Bot(Discord.Net)等待回复?

时间:2019-10-28 15:39:27

标签: c# discord.net

所以我是一个不和谐的机器人,它使您可以在基于回合的战斗系统中与人战斗。我要发出一条命令,要求两个玩家都确认是否要像这样战斗:

用户1:+ duel用户2
Bot:确定要与User2决斗吗?
使用者1:是
机器人:@ User2 User1向您挑战了决斗,您接受吗?
使用者2:是
机器人:让战斗开始吧!

我已经设置了剩下的代码来提及播放器并发送消息等,但是如何等待回复?我知道在discord.js中使用MessageCollector类是可能的,但是我不知道如何在Discord.Net中做到这一点,而且通过谷歌搜索还没有找到任何答案。

这是我到目前为止的代码:

[Command("duel")]
public async Task Duel([Remainder]string args) {
   await Context.Channel.SendMessageAsync($"Are you sure you want to duel {args}?");
   var reply = //Somehow get the reply
   if (reply.ToLower() == "yes") continue;
   var enemy = Functions.GetUser(args, Context.Guild.Users) //Gets the desired player from the guild
   if (enemy != null) continue;
   await Context.Channel.SendMessageAsync($"{enemy.Mention} {Context.User.Username} has challanged you to a duel, do you accept?")
   reply = //Somehow get the reply again
   if (reply.toLower() == "yes") continue;

   //Some other code to start the battle

}

0 个答案:

没有答案
相关问题