Vb.net 在discord中检查用户回复
我如何检查提到的用户回复的if语句Vb.net 在discord中检查用户回复,vb.net,json.net,discord,discord.net,Vb.net,Json.net,Discord,Discord.net,我如何检查提到的用户回复的if语句 <Command("test")> <[Alias]("test1")> <Summary("testing")> Public Async Function TestAsync(Optional ByVal user As SocketGuildUser = Nothing) As Task Await ReplyAsync
<Command("test")>
<[Alias]("test1")>
<Summary("testing")>
Public Async Function TestAsync(Optional ByVal user As SocketGuildUser = Nothing) As Task
Await ReplyAsync(Context.User.Mention & " is waiting for " & $"{user.Mention}" & " answer")
If ??? = "ready" Then
Await ReplyAsync($"{user.Mention}" & "is ready")
Else
Await ReplyAsync($"{user.Mention}" & "is not ready")
End If
End Function
公共异步函数TestAsync(可选ByVal用户作为SocketGuildUser=Nothing)作为任务
wait replysync(Context.User.title&“正在等待”&$“{User.title}”&“应答”)
如果???=准备好了吗
等待replysync($“{user.notice}”和“准备就绪”)
其他的
wait replysync($“{user.antify}”&“尚未准备就绪”)
如果结束
端函数
如何检查提到的用户回复中的if语句?您需要使用Discord.Addons.Interactive包-遗憾的是,没有很好的文档
<Command("test")>
<[Alias]("test1")>
<Summary("testing")>
Public Async Function TestAsync(Optional ByVal user As SocketGuildUser = Nothing) As Task
Await ReplyAsync(Context.User.Mention & " is waiting for " & $"{user.Mention}" & " answer")
If ??? = "ready" Then
Await ReplyAsync($"{user.Mention}" & "is ready")
Else
Await ReplyAsync($"{user.Mention}" & "is not ready")
End If
End Function
将其添加到项目后,需要切换命令类以从InteractiveBase继承,将命令的运行模式设置为Async,并使用NextMessageAsync
方法等待discord通道中的消息答复
Public Class TestCommands
Inherits InteractiveBase
<Command("test", RunMode:=RunMode.Async)>
<[Alias]("test1")>
<Summary("testing")>
Public Async Function TestAsync(ByVal Optional user As SocketGuildUser = Nothing) As Task
Await ReplyAsync(Context.User.Mention & " is waiting for " & $"{user.Mention}" & " answer")
Dim userResponse = Await NextMessageAsync(timeout:=TimeSpan.FromMinutes(2))
If userResponse IsNot Nothing Then
Await ReplyAsync($"{user.Mention}" & "is ready")
Else
Await ReplyAsync($"{user.Mention}" & "is not ready")
End If
End Function
End Class
公共类TestCommands
继承InteractiveBase
公共异步函数TestAsync(ByVal可选用户为SocketGuildUser=Nothing)作为任务
wait replysync(Context.User.title&“正在等待”&$“{User.title}”&“应答”)
Dim userResponse=WAIT NextMessageAsync(超时:=TimeSpan.FromMinutes(2))
如果userResponse不是空的,那么
等待replysync($“{user.notice}”和“准备就绪”)
其他的
wait replysync($“{user.antify}”&“尚未准备就绪”)
如果结束
端函数
末级
NextMessageAsync方法有一些重载,可以让您确保您想要的用户就是回复的用户。此软件包的说明是:“要使用,请向您的服务提供商添加一个InteractiveService。”您能解释一下我如何做到这一点吗?您需要(并且应该是)使用Then,当您有了该设置时,只需将InteractiveService添加到您的服务提供者/容器中即可。类似于
.AddSingleton(newInteractiveService())
@Newbie.Noob的东西这对你有用吗?不,我正在尝试其他方法()