我正在尝试使用Discord.js制作一个小的Discord机器人,但是在我的管理命令中,它在尝试将播放器添加到表时会抛出此错误:
C:\用户\马克\桌面\ DiscCentral \ bot.js:49 if(ServerAdmins [1]){ ^
Function RegSplit(szPattern, szStr)
Dim oAl, oRe, oMatches
Set oRe = New RegExp
oRe.Pattern = "^(.*)(" & szPattern & ")(.*)$"
oRe.IgnoreCase = True
oRe.Global = True
Set oAl = CreateObject("System.Collections.ArrayList")
Do
Set oMatches = oRe.Execute(szStr)
If oMatches.Count > 0 Then
oAl.Add oMatches(0).SubMatches(2)
szStr = oMatches(0).SubMatches(0)
Else
oAl.Add szStr
Exit Do
End If
Loop
oAl.Reverse
RegSplit = oAl.ToArray
End Function
'**************************************************************
Dim A
A = RegSplit("[,|;|#]", "bob,;joe;tony#bill")
WScript.Echo Join(A, vbCrLf)
Returns:
bob
joe
tony
bill
继承我的代码:
TypeError: Cannot read property '1' of undefined
at Client.client.on (C:\Users\Mark\Desktop\DiscCentral\bot.js:49:20)
at emitOne (events.js:116:13)
at Client.emit (events.js:211:7)
at MessageCreateHandler.handle (C:\Users\Mark\Desktop\DiscCentral\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\Mark\Desktop\DiscCentral\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\Mark\Desktop\DiscCentral\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\Mark\Desktop\DiscCentral\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (C:\Users\Mark\Desktop\DiscCentral\node_modules\discord.js\node_modules\ws\lib\event-target.js:120:16)
at emitOne (events.js:116:13)
at WebSocket.emit (events.js:211:7)
我假设问题是我在表中使用了一个表,但我不知道如何以任何其他方式为每个服务器分配排名。
关于我应该做什么的任何建议?
答案 0 :(得分:0)
您的代码中似乎没有声明Admins
变量,至少是您提供的代码。告诉我们你如何定义它?就在现在,这就是为什么它会给你错误。