Advertisement
JustJoos

Untitled

May 5th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.37 KB | None | 0 0
  1. Imports Discord
  2. Imports Discord.WebSocket
  3.  
  4. Imports PlayerIOClient
  5. Imports System.IO
  6.  
  7. Imports Random
  8.  
  9. Public Class Form1
  10.  
  11. Public Con As Connection
  12. Public Client As Client
  13. Public isConnected As Boolean
  14.  
  15. Public email As String
  16. Public pass As String
  17. Public worldid As String
  18. Public _opt As String
  19.  
  20. Public usr
  21.  
  22. Public users As Dictionary(Of Integer, String) = New Dictionary(Of Integer, String)
  23.  
  24. Public defaultIcons As New List(Of Integer)({0, 1, 2, 3, 4, 5, 13, 18, 19, 21})
  25. Public pendingUser As New List(Of String)
  26. Public connectedUser As New Dictionary(Of String, Integer)
  27. Public connectedUserConfirm As New Dictionary(Of String, Boolean)
  28. Public userAccounts As New Dictionary(Of String, String)
  29.  
  30. Dim discord As DiscordSocketClient
  31. Dim user As SocketGuildUser
  32. Dim Trigger As String = ";"
  33.  
  34. Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
  35.  
  36. Try
  37. discord = New DiscordSocketClient(New DiscordSocketConfig With {
  38. .WebSocketProvider = Net.WebSockets.DefaultWebSocketProvider.Instance,
  39. .UdpSocketProvider = Net.Udp.DefaultUdpSocketProvider.Instance,
  40. .MessageCacheSize = 50
  41. })
  42.  
  43. AddHandler discord.MessageReceived, AddressOf onMsg
  44.  
  45. Await discord.LoginAsync(TokenType.Bot, "token")
  46. Await discord.StartAsync()
  47. Label2.Text = "EEConnect is running."
  48. Await discord.SetGameAsync("Everybody Edits!")
  49.  
  50. Catch ex As Exception
  51. MessageBox.Show(ex.Message)
  52. Label2.Text = "EEConnect is not running."
  53. End Try
  54. End Sub
  55.  
  56. Private Async Sub Form1_Closing(sender As Object, e As EventArgs) Handles Me.Closing
  57. Await discord.StopAsync()
  58. Await discord.LogoutAsync()
  59. Label2.Text = "EEConnected is not running."
  60. End Sub
  61.  
  62. Public Async Function onMsg(message As SocketMessage) As Task
  63.  
  64. Dim msg As String = message.Content
  65. Dim MsgSender As String = message.Author.Username
  66. Dim MsgSenderID As String = message.Author.Id
  67.  
  68.  
  69. If message.Source = MessageSource.Bot Then
  70. 'ignore
  71. Else
  72. If msg.StartsWith(Trigger) Then
  73. If isConnected = True Then
  74. If msg.Contains(" ") Then
  75. Dim cmd As String = msg.Split(Trigger)(1).Split(" ")(0)
  76. Dim arg As String = msg.Split(" ")(1)
  77.  
  78. Select Case cmd.ToLower
  79. Case "connect"
  80. If Not pendingUser.Contains(arg.ToLower) Or connectedUser.ContainsKey(arg.ToLower) Then
  81. Dim builder = New EmbedBuilder()
  82. builder.AddField("Connect Your Account", "Please connect your discord account with your everybody edits" & vbNewLine & " account! https://everybodyedits.com/games/PW7ixGoi4EbEI", True)
  83. builder.WithColor(Color.Red)
  84. Await message.Channel.SendMessageAsync("", False, builder.Build())
  85.  
  86. pendingUser.Add(arg.ToLower)
  87. userAccounts.Add(arg.ToLower, MsgSenderID) ' Adds user to pending user list and attaches username to discord ID.
  88. connectedUserConfirm.Add(arg.ToLower, False)
  89.  
  90. Else
  91. Dim builder = New EmbedBuilder()
  92. builder.AddField("Error", "We are already looking for that account!" & vbNewLine & "Please remove this account with ;stop.", True)
  93. builder.WithColor(Color.DarkRed)
  94. Await message.Channel.SendMessageAsync("", False, builder.Build())
  95. End If
  96.  
  97. Case "stop"
  98.  
  99. If pendingUser.Contains(arg.ToLower) Then
  100. pendingUser.Remove(arg.ToLower)
  101. userAccounts.Remove(arg.ToLower) ' Removes pending username from list
  102. connectedUserConfirm.Remove(arg.ToLower)
  103.  
  104. Dim builder = New EmbedBuilder()
  105. builder.AddField("Verification Failed", "You cancelled your request. Please try ;connect" & vbNewLine & "again and reconnect to the world.", True)
  106. builder.WithColor(Color.DarkRed)
  107. Await message.Channel.SendMessageAsync("", False, builder.Build())
  108. Else
  109. Dim builder = New EmbedBuilder()
  110. builder.AddField("Error", "We couldn't find that account in the pending" & vbNewLine & "list. Please try again.", True)
  111. builder.WithColor(Color.DarkRed)
  112. Await message.Channel.SendMessageAsync("", False, builder.Build())
  113. End If
  114.  
  115. Case Else
  116.  
  117. Await message.Channel.SendMessageAsync("Invalid command!")
  118.  
  119. End Select
  120.  
  121. Else
  122. Dim cmd As String = msg.Split(Trigger)(1)
  123.  
  124. Select Case cmd.ToLower
  125. Case "connect"
  126.  
  127. Await message.Channel.SendMessageAsync("Missing username!")
  128.  
  129. Case "stop"
  130.  
  131. Await message.Channel.SendMessageAsync("Missing username!")
  132.  
  133. Case Else
  134.  
  135. Await message.Channel.SendMessageAsync("Invalid command!")
  136.  
  137. End Select
  138.  
  139. End If
  140.  
  141. Else
  142.  
  143. Await message.Channel.SendMessageAsync("The EE bot is not connected. Please contact an admin.")
  144.  
  145. End If
  146.  
  147. Else
  148. 'ignore
  149. End If
  150.  
  151. End If
  152.  
  153. End Function
  154.  
  155. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  156. '''''''''''''''''''''''''''''' EE SIDE '''''''''''''''''''''''''''''''''
  157. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  158.  
  159.  
  160. Public Sub say(ByVal message As String)
  161. If isConnected = True Then
  162. Con.Send("say", message)
  163. End If
  164. End Sub
  165.  
  166. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  167.  
  168. If isConnected = False Then
  169.  
  170. Try
  171.  
  172. email = TextBox1.Text
  173. pass = TextBox2.Text
  174. worldid = TextBox3.Text
  175.  
  176. Client = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", email, pass, Nothing)
  177.  
  178. Con = Client.Multiplayer.CreateJoinRoom(worldid, "public", True, New Dictionary(Of String, String), New Dictionary(Of String, String))
  179.  
  180. Con.Send("init")
  181. Con.AddOnMessage(New MessageReceivedEventHandler(AddressOf handlemsg))
  182.  
  183. isConnected = True
  184.  
  185. Button1.Text = "Disconnect"
  186.  
  187. Catch ex As Exception
  188.  
  189. MsgBox("Failed to connect.")
  190.  
  191. End Try
  192. Else
  193.  
  194. Con.Disconnect()
  195. isConnected = False
  196. Button1.Text = "Connect"
  197.  
  198. End If
  199. End Sub
  200.  
  201.  
  202. Public Sub handlemsg(ByVal sender As Object, ByVal m As PlayerIOClient.Message)
  203.  
  204.  
  205. ' Connection of bot '
  206.  
  207. If m.Type = "init" Then
  208.  
  209. Con.Send("init2")
  210.  
  211. say("[EEConnect] Connected!")
  212.  
  213. Con.Send("m", 5 * 16, 5 * 16, 0, 0, 0, 0, 0, 0, 0, False, False, 0)
  214.  
  215. ' Gets players usernames and IDs to be recalled later '
  216.  
  217. ElseIf m.Type = "add" Then
  218.  
  219. Dim rnd = New Random()
  220. Dim randomID = defaultIcons(rnd.Next(0, defaultIcons.Count))
  221.  
  222. If Not users.ContainsKey(m.GetInteger(0)) Then
  223.  
  224. users.Add(m.GetInteger(0), m.GetString(1))
  225. usr = users(m.GetInteger(0)).ToLower
  226.  
  227. If pendingUser.Contains(usr) Then
  228.  
  229. say("/tp " & usr & " 5 1")
  230. say("We have detected your account! Please return to discord " & usr & ".")
  231. pendingUser.Remove(usr)
  232. connectedUser.Add(usr, randomID)
  233.  
  234. Select Case randomID
  235. Case "0"
  236. Dim builder = New EmbedBuilder()
  237. builder.AddField("Verification", "Please verify it's you by changing your smiley" & vbNewLine & "to this one! When you do you will be let in!", True)
  238. builder.WithThumbnailUrl("https://i.imgur.com/nTkVPGM.png")
  239. builder.WithColor(Color.Red)
  240. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  241. Case "1"
  242. Dim builder = New EmbedBuilder()
  243. builder.AddField("Verification", "Please verify it's you by changing your smiley" & vbNewLine & "to this one! When you do you will be let in!", True)
  244. builder.WithThumbnailUrl("https://i.imgur.com/tkaO1qS.png")
  245. builder.WithColor(Color.Red)
  246. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  247. Case "2"
  248. Dim builder = New EmbedBuilder()
  249. builder.AddField("Verification", "Please verify it's you by changing your smiley" & vbNewLine & "to this one! When you do you will be let in!", True)
  250. builder.WithThumbnailUrl("https://i.imgur.com/rGVeTGg.png")
  251. builder.WithColor(Color.Red)
  252. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  253. Case "3"
  254. Dim builder = New EmbedBuilder()
  255. builder.AddField("Verification", "Please verify it's you by changing your smiley" & vbNewLine & "to this one! When you do you will be let in!", True)
  256. builder.WithThumbnailUrl("https://i.imgur.com/JixEITm.png")
  257. builder.WithColor(Color.Red)
  258. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  259. Case "4"
  260. Dim builder = New EmbedBuilder()
  261. builder.AddField("Verification", "Please verify it's you by changing your smiley" & vbNewLine & "to this one! When you do you will be let in!", True)
  262. builder.WithThumbnailUrl("https://i.imgur.com/TF4K8Ir.png")
  263. builder.WithColor(Color.Red)
  264. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  265. Case "5"
  266. Dim builder = New EmbedBuilder()
  267. builder.AddField("Verification", "Please verify it's you by changing your smiley" & vbNewLine & "to this one! When you do you will be let in!", True)
  268. builder.WithThumbnailUrl("https://i.imgur.com/ngB4fzu.png")
  269. builder.WithColor(Color.Red)
  270. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  271. Case "14"
  272. Dim builder = New EmbedBuilder()
  273. builder.AddField("Verification", "Please verify it's you by changing your smiley" & vbNewLine & "to this one! When you do you will be let in!", True)
  274. builder.WithThumbnailUrl("https://i.imgur.com/gZAbFCg.png")
  275. builder.WithColor(Color.Red)
  276. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  277. Case "18"
  278. Dim builder = New EmbedBuilder()
  279. builder.AddField("Verification", "Please verify it's you by changing your smiley" & vbNewLine & "to this one! When you do you will be let in!", True)
  280. builder.WithThumbnailUrl("https://i.imgur.com/1T8tdMC.png")
  281. builder.WithColor(Color.Red)
  282. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  283. Case "19"
  284. Dim builder = New EmbedBuilder()
  285. builder.AddField("Verification", "Please verify it's you by changing your smiley" & vbNewLine & "to this one! When you do you will be let in!", True)
  286. builder.WithThumbnailUrl("https://i.imgur.com/J8Q9D4H.png")
  287. builder.WithColor(Color.Red)
  288. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  289. End Select
  290.  
  291. connectedUserConfirm(usr) = True
  292.  
  293.  
  294. ElseIf Not users(m.GetInteger(0)).ToLower = "wow" Then
  295.  
  296. say("/kick " & users(m.GetInteger(0)) & " We don't detect you trying to connect your account with our discord server.")
  297.  
  298. End If
  299. End If
  300.  
  301. ElseIf m.Type = "left" Then
  302. If users.ContainsKey(m.GetInteger(0)) Then
  303.  
  304. usr = users(m.GetInteger(0)).ToLower
  305.  
  306. If pendingUser.Contains(usr) Then
  307. Dim builder = New EmbedBuilder()
  308. builder.AddField("Verification Failed", "Your user left the world. Please try ;connect" & vbNewLine & "again and reconnect to the world.", True)
  309. builder.WithColor(Color.DarkRed)
  310. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  311. pendingUser.Remove(usr)
  312. connectedUserConfirm.Remove(usr)
  313. End If
  314.  
  315. If connectedUser.ContainsKey(usr) Then
  316. Dim builder = New EmbedBuilder()
  317. builder.AddField("Verification Failed", "Your user left the world. Please try ;connect" & vbNewLine & "again and reconnect to the world.", True)
  318. builder.WithColor(Color.DarkRed)
  319. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  320. connectedUser.Remove(usr)
  321. connectedUserConfirm.Remove(usr)
  322. End If
  323.  
  324. users.Remove(m.GetInteger(0))
  325. End If
  326.  
  327. ElseIf m.Type = "face" Then
  328.  
  329. usr = users(m.GetInteger(0)).ToLower
  330.  
  331. Dim smiley As Integer = m.GetInteger(1)
  332. Dim newNick As String = usr.ToUpper
  333.  
  334. If connectedUser(usr) = smiley.ToString And connectedUserConfirm(usr) = True Then
  335.  
  336. say("/tp " & usr & " 9 1")
  337. Dim builder = New EmbedBuilder()
  338. builder.AddField("Verification Success!", "You have successfully linked your EE account " & vbNewLine & "(" & users(m.GetInteger(0)) & ") and your discord account!", True)
  339. builder.WithColor(Color.Green)
  340. discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
  341. discord.GetGuild(TextBox4.Text).GetUser(userAccounts(usr)).ModifyAsync(Sub(u) u.Nickname = newNick)
  342.  
  343.  
  344. connectedUser.Remove(usr)
  345. connectedUserConfirm.Remove(usr)
  346.  
  347. End If
  348.  
  349. End If
  350.  
  351. End Sub
  352. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement