微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

尝试创建 Discord DM

如何解决尝试创建 Discord DM

我在 vb.net 中编写了一个 discord 机器人,用于在用户最初加入我的服务器后向其发送消息。在测试中,我完全没有遇到任何问题。我以所有者身份使用命令触发它,并使用我加入服务器的家庭成员帐户触发它。

但是,自从打开机器人后第一次真正的用户加入时,我在尝试创建我以前从未收到过的 DM 对话时遇到了异常。

相关代码为:

Dim conversations As New Dictionary(Of ULong,Dictionary(Of String,String))
Private Function HandleUserJoined(user As SocketGuildUser) Handles client.UserJoined
    conversations.Add(user.Id,New Dictionary(Of String,String) From {{"guild",user.Guild.Id},{"awaiting","name"},{"discordid",user.Id}})
    user.SendMessageAsync($"Hello,{user.Nickname}! Welcome to the Neighborhood discord Server!")
End Function

错误报告的前几行(有85行):(注意第112行是conversations.add,但错误提示问题出在“GetorCreateDMChannelAsync”)

Unhandled Exception: System.Runtime.InteropServices.SEHException: External component has thrown an exception.
   at discord.WebSocket.socketUser.<GetorCreateDMChannelAsync>d__35.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at discord.WebSocket.socketUser.GetorCreateDMChannelAsync(RequestOptions options)
   at discord.UserExtensions.<SendMessageAsync>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at discord.UserExtensions.SendMessageAsync(IUser user,String text,Boolean isTTS,Embed embed,RequestOptions options)
   at SWNABot.Module1.HandleUserJoined(SocketGuildUser user) in C:\Users\ssher\source\repos\SWNABot\Module1.vb:line 112
   at SWNABot.Module1._Closure$__._Lambda$__R9-1(SocketGuildUser a0)
   at discord.EventExtensions.<InvokeAsync>d__1`1.MoveNext()

是什么导致了这个错误

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。