使用.vbs发送不和谐消息时的语法错误
我最近想创建一个脚本,该脚本可以使我可以从不同帐户发送消息而不登录每个帐户(我知道不和谐的mutliple帐户容量),但是您知道...挑战\ (ツ)/) 因此,我最初找到了一个非常基本的脚本,您需要在每次发送消息时进行编辑。所以我想尝试制作UI。我刚刚粘贴了我的代码中的发送功能。这是我想到的(它是为法国用户设计
On Error Resume Next
'Token selector dialogue box
account=InputBox("Merci d'indiquer le nom du compte ci-dessous","Discord CMD","")
'If user cancels, exit the program
if IsEmpty(account) Then
WScript.Quit
end if
'Check if token is registered
Const ForReading = 1
Dim File, content, FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Function FileExists(FilePath)
If fso.FileExists(FilePath) Then
FileExists=CBool(1)
Else
FileExists=CBool(0)
End If
End Function
If FileExists("database\accounts\"+account+".bin") Then
'If the file exist, do nothing and continue the script
WScript.Sleep(500)
Else
'If the file doesn't exist, restart the script and display an error
x=msgbox("This account has not be registered in the database. Please try again.", 0+16, "Error - Does not exist")
CreateObject("WScript.Shell").Run "Chat.vbs"
WScript.Quit
End If
'Get the token related the account asked
Set File = fso.OpenTextFile("database\accounts\"+account+".bin", ForReading)
Token = File.ReadAll
'Loop
Do
'Choose channel
Echannel=InputBox("Merci d'indiquer l'identifiant du channel ci-dessous. Si il est identique, inscrivez 'Channel'","Discord CMD - " + account,"Channel")
If (Echannel="Channel") Then
'If the channel is the same as before, then we don't change it in the code
WScript.Sleep(500)
Else
'If the channel is different, we change to the new value
channels = Echannel
End If
'If user cancels, restart the program
if IsEmpty(account) Then
CreateObject("WScript.Shell").Run "Chat.vbs"
WScript.Quit
end if
'The user enters his message
text=InputBox("Merci d'indiquer le texte ci-dessous, faites OK pour l'envoyer","Discord CMD - " + account + " - Writing...","")
'If user cancels, restart the program
if IsEmpty(account) Then
CreateObject("WScript.Shell").Run "Chat.vbs"
WScript.Quit
end if
'We send the message
Call commandeexercuter(channels,Token,text)
Function commandeexercuter(channels,Token,text)
Set objXmlHttp = CreateObject("Msxml2.ServerXMLHTTP")
sRequest = "{" & Chr(34) & "content" & Chr(34) & ": " & Chr(34) & text & Chr(34) & "}"
objXmlHttp.open "POST","https://discordapp.com/api/v6/channels/" & channels &"/messages", False
objXmlHttp.setRequestHeader "Authorization", Token
objXmlHttp.setRequestHeader "Content-Type", "application/json"
objXmlHttp.send(sRequest)
End Function
'We restart the loop
Loop
的)说语法不正确...
有人可以帮我吗? 祝你今天过得愉快 ;)
I recently wanted to create a script that would allow me to send messages from my different accounts without logging in/out of each one on Discord (I know that there is mutliple accounts capacity on Discord but you know... Challenge ¯\(ツ)/¯ )
So, I originally found a very basic script that you needed to edit each time you wanted to send a message. So I wanted to try to make a UI. I just pasted the send fuction in my code. Here's what I came up with (it's designed for french users so don't mind the text displayed ;) ):
On Error Resume Next
'Token selector dialogue box
account=InputBox("Merci d'indiquer le nom du compte ci-dessous","Discord CMD","")
'If user cancels, exit the program
if IsEmpty(account) Then
WScript.Quit
end if
'Check if token is registered
Const ForReading = 1
Dim File, content, FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Function FileExists(FilePath)
If fso.FileExists(FilePath) Then
FileExists=CBool(1)
Else
FileExists=CBool(0)
End If
End Function
If FileExists("database\accounts\"+account+".bin") Then
'If the file exist, do nothing and continue the script
WScript.Sleep(500)
Else
'If the file doesn't exist, restart the script and display an error
x=msgbox("This account has not be registered in the database. Please try again.", 0+16, "Error - Does not exist")
CreateObject("WScript.Shell").Run "Chat.vbs"
WScript.Quit
End If
'Get the token related the account asked
Set File = fso.OpenTextFile("database\accounts\"+account+".bin", ForReading)
Token = File.ReadAll
'Loop
Do
'Choose channel
Echannel=InputBox("Merci d'indiquer l'identifiant du channel ci-dessous. Si il est identique, inscrivez 'Channel'","Discord CMD - " + account,"Channel")
If (Echannel="Channel") Then
'If the channel is the same as before, then we don't change it in the code
WScript.Sleep(500)
Else
'If the channel is different, we change to the new value
channels = Echannel
End If
'If user cancels, restart the program
if IsEmpty(account) Then
CreateObject("WScript.Shell").Run "Chat.vbs"
WScript.Quit
end if
'The user enters his message
text=InputBox("Merci d'indiquer le texte ci-dessous, faites OK pour l'envoyer","Discord CMD - " + account + " - Writing...","")
'If user cancels, restart the program
if IsEmpty(account) Then
CreateObject("WScript.Shell").Run "Chat.vbs"
WScript.Quit
end if
'We send the message
Call commandeexercuter(channels,Token,text)
Function commandeexercuter(channels,Token,text)
Set objXmlHttp = CreateObject("Msxml2.ServerXMLHTTP")
sRequest = "{" & Chr(34) & "content" & Chr(34) & ": " & Chr(34) & text & Chr(34) & "}"
objXmlHttp.open "POST","https://discordapp.com/api/v6/channels/" & channels &"/messages", False
objXmlHttp.setRequestHeader "Authorization", Token
objXmlHttp.setRequestHeader "Content-Type", "application/json"
objXmlHttp.send(sRequest)
End Function
'We restart the loop
Loop
The only problem is that when I start the script, it returns an error and the last Function (the one that was working before) saying that the syntax isn't correct...
Can someone help me please?
Have a nice day ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法在DO循环中定义功能。您只需在最后一行之后就将函数声明移出循环之外:
我建议您在脚本的开头或结尾将所有功能分组在一起。
您也可以简单地将
CommandeeXercuter
代码直接放入循环中,因为您没有在其他任何地方使用该功能:You cannot define a Function inside a Do Loop. You san simply move the Function declaration outside the loop, right after the last line:
I suggest you group all your functions together at the beginning or end of your script.
You can also simply place the
commandeexercuter
code in your loop directly since you are not using that function anywhere else: