Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Discord
- Imports Discord.WebSocket
- Imports PlayerIOClient
- Imports System.IO
- Imports Random
- Public Class Form1
- Public Con As Connection
- Public Client As Client
- Public isConnected As Boolean
- Public email As String
- Public pass As String
- Public worldid As String
- Public _opt As String
- Public usr
- Public users As Dictionary(Of Integer, String) = New Dictionary(Of Integer, String)
- Public defaultIcons As New List(Of Integer)({0, 1, 2, 3, 4, 5, 13, 18, 19, 21})
- Public pendingUser As New List(Of String)
- Public connectedUser As New Dictionary(Of String, Integer)
- Public connectedUserConfirm As New Dictionary(Of String, Boolean)
- Public userAccounts As New Dictionary(Of String, String)
- Dim discord As DiscordSocketClient
- Dim user As SocketGuildUser
- Dim Trigger As String = ";"
- Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
- Try
- discord = New DiscordSocketClient(New DiscordSocketConfig With {
- .WebSocketProvider = Net.WebSockets.DefaultWebSocketProvider.Instance,
- .UdpSocketProvider = Net.Udp.DefaultUdpSocketProvider.Instance,
- .MessageCacheSize = 50
- })
- AddHandler discord.MessageReceived, AddressOf onMsg
- Await discord.LoginAsync(TokenType.Bot, "token")
- Await discord.StartAsync()
- Label2.Text = "EEConnect is running."
- Await discord.SetGameAsync("Everybody Edits!")
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- Label2.Text = "EEConnect is not running."
- End Try
- End Sub
- Private Async Sub Form1_Closing(sender As Object, e As EventArgs) Handles Me.Closing
- Await discord.StopAsync()
- Await discord.LogoutAsync()
- Label2.Text = "EEConnected is not running."
- End Sub
- Public Async Function onMsg(message As SocketMessage) As Task
- Dim msg As String = message.Content
- Dim MsgSender As String = message.Author.Username
- Dim MsgSenderID As String = message.Author.Id
- If message.Source = MessageSource.Bot Then
- 'ignore
- Else
- If msg.StartsWith(Trigger) Then
- If isConnected = True Then
- If msg.Contains(" ") Then
- Dim cmd As String = msg.Split(Trigger)(1).Split(" ")(0)
- Dim arg As String = msg.Split(" ")(1)
- Select Case cmd.ToLower
- Case "connect"
- If Not pendingUser.Contains(arg.ToLower) Or connectedUser.ContainsKey(arg.ToLower) Then
- Dim builder = New EmbedBuilder()
- builder.AddField("Connect Your Account", "Please connect your discord account with your everybody edits" & vbNewLine & " account! https://everybodyedits.com/games/PW7ixGoi4EbEI", True)
- builder.WithColor(Color.Red)
- Await message.Channel.SendMessageAsync("", False, builder.Build())
- pendingUser.Add(arg.ToLower)
- userAccounts.Add(arg.ToLower, MsgSenderID) ' Adds user to pending user list and attaches username to discord ID.
- connectedUserConfirm.Add(arg.ToLower, False)
- Else
- Dim builder = New EmbedBuilder()
- builder.AddField("Error", "We are already looking for that account!" & vbNewLine & "Please remove this account with ;stop.", True)
- builder.WithColor(Color.DarkRed)
- Await message.Channel.SendMessageAsync("", False, builder.Build())
- End If
- Case "stop"
- If pendingUser.Contains(arg.ToLower) Then
- pendingUser.Remove(arg.ToLower)
- userAccounts.Remove(arg.ToLower) ' Removes pending username from list
- connectedUserConfirm.Remove(arg.ToLower)
- Dim builder = New EmbedBuilder()
- builder.AddField("Verification Failed", "You cancelled your request. Please try ;connect" & vbNewLine & "again and reconnect to the world.", True)
- builder.WithColor(Color.DarkRed)
- Await message.Channel.SendMessageAsync("", False, builder.Build())
- Else
- Dim builder = New EmbedBuilder()
- builder.AddField("Error", "We couldn't find that account in the pending" & vbNewLine & "list. Please try again.", True)
- builder.WithColor(Color.DarkRed)
- Await message.Channel.SendMessageAsync("", False, builder.Build())
- End If
- Case Else
- Await message.Channel.SendMessageAsync("Invalid command!")
- End Select
- Else
- Dim cmd As String = msg.Split(Trigger)(1)
- Select Case cmd.ToLower
- Case "connect"
- Await message.Channel.SendMessageAsync("Missing username!")
- Case "stop"
- Await message.Channel.SendMessageAsync("Missing username!")
- Case Else
- Await message.Channel.SendMessageAsync("Invalid command!")
- End Select
- End If
- Else
- Await message.Channel.SendMessageAsync("The EE bot is not connected. Please contact an admin.")
- End If
- Else
- 'ignore
- End If
- End If
- End Function
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- '''''''''''''''''''''''''''''' EE SIDE '''''''''''''''''''''''''''''''''
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- Public Sub say(ByVal message As String)
- If isConnected = True Then
- Con.Send("say", message)
- End If
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- If isConnected = False Then
- Try
- email = TextBox1.Text
- pass = TextBox2.Text
- worldid = TextBox3.Text
- Client = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", email, pass, Nothing)
- Con = Client.Multiplayer.CreateJoinRoom(worldid, "public", True, New Dictionary(Of String, String), New Dictionary(Of String, String))
- Con.Send("init")
- Con.AddOnMessage(New MessageReceivedEventHandler(AddressOf handlemsg))
- isConnected = True
- Button1.Text = "Disconnect"
- Catch ex As Exception
- MsgBox("Failed to connect.")
- End Try
- Else
- Con.Disconnect()
- isConnected = False
- Button1.Text = "Connect"
- End If
- End Sub
- Public Sub handlemsg(ByVal sender As Object, ByVal m As PlayerIOClient.Message)
- ' Connection of bot '
- If m.Type = "init" Then
- Con.Send("init2")
- say("[EEConnect] Connected!")
- Con.Send("m", 5 * 16, 5 * 16, 0, 0, 0, 0, 0, 0, 0, False, False, 0)
- ' Gets players usernames and IDs to be recalled later '
- ElseIf m.Type = "add" Then
- Dim rnd = New Random()
- Dim randomID = defaultIcons(rnd.Next(0, defaultIcons.Count))
- If Not users.ContainsKey(m.GetInteger(0)) Then
- users.Add(m.GetInteger(0), m.GetString(1))
- usr = users(m.GetInteger(0)).ToLower
- If pendingUser.Contains(usr) Then
- say("/tp " & usr & " 5 1")
- say("We have detected your account! Please return to discord " & usr & ".")
- pendingUser.Remove(usr)
- connectedUser.Add(usr, randomID)
- Select Case randomID
- Case "0"
- Dim builder = New EmbedBuilder()
- 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)
- builder.WithThumbnailUrl("https://i.imgur.com/nTkVPGM.png")
- builder.WithColor(Color.Red)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- Case "1"
- Dim builder = New EmbedBuilder()
- 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)
- builder.WithThumbnailUrl("https://i.imgur.com/tkaO1qS.png")
- builder.WithColor(Color.Red)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- Case "2"
- Dim builder = New EmbedBuilder()
- 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)
- builder.WithThumbnailUrl("https://i.imgur.com/rGVeTGg.png")
- builder.WithColor(Color.Red)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- Case "3"
- Dim builder = New EmbedBuilder()
- 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)
- builder.WithThumbnailUrl("https://i.imgur.com/JixEITm.png")
- builder.WithColor(Color.Red)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- Case "4"
- Dim builder = New EmbedBuilder()
- 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)
- builder.WithThumbnailUrl("https://i.imgur.com/TF4K8Ir.png")
- builder.WithColor(Color.Red)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- Case "5"
- Dim builder = New EmbedBuilder()
- 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)
- builder.WithThumbnailUrl("https://i.imgur.com/ngB4fzu.png")
- builder.WithColor(Color.Red)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- Case "14"
- Dim builder = New EmbedBuilder()
- 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)
- builder.WithThumbnailUrl("https://i.imgur.com/gZAbFCg.png")
- builder.WithColor(Color.Red)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- Case "18"
- Dim builder = New EmbedBuilder()
- 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)
- builder.WithThumbnailUrl("https://i.imgur.com/1T8tdMC.png")
- builder.WithColor(Color.Red)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- Case "19"
- Dim builder = New EmbedBuilder()
- 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)
- builder.WithThumbnailUrl("https://i.imgur.com/J8Q9D4H.png")
- builder.WithColor(Color.Red)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- End Select
- connectedUserConfirm(usr) = True
- ElseIf Not users(m.GetInteger(0)).ToLower = "wow" Then
- say("/kick " & users(m.GetInteger(0)) & " We don't detect you trying to connect your account with our discord server.")
- End If
- End If
- ElseIf m.Type = "left" Then
- If users.ContainsKey(m.GetInteger(0)) Then
- usr = users(m.GetInteger(0)).ToLower
- If pendingUser.Contains(usr) Then
- Dim builder = New EmbedBuilder()
- builder.AddField("Verification Failed", "Your user left the world. Please try ;connect" & vbNewLine & "again and reconnect to the world.", True)
- builder.WithColor(Color.DarkRed)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- pendingUser.Remove(usr)
- connectedUserConfirm.Remove(usr)
- End If
- If connectedUser.ContainsKey(usr) Then
- Dim builder = New EmbedBuilder()
- builder.AddField("Verification Failed", "Your user left the world. Please try ;connect" & vbNewLine & "again and reconnect to the world.", True)
- builder.WithColor(Color.DarkRed)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- connectedUser.Remove(usr)
- connectedUserConfirm.Remove(usr)
- End If
- users.Remove(m.GetInteger(0))
- End If
- ElseIf m.Type = "face" Then
- usr = users(m.GetInteger(0)).ToLower
- Dim smiley As Integer = m.GetInteger(1)
- Dim newNick As String = usr.ToUpper
- If connectedUser(usr) = smiley.ToString And connectedUserConfirm(usr) = True Then
- say("/tp " & usr & " 9 1")
- Dim builder = New EmbedBuilder()
- builder.AddField("Verification Success!", "You have successfully linked your EE account " & vbNewLine & "(" & users(m.GetInteger(0)) & ") and your discord account!", True)
- builder.WithColor(Color.Green)
- discord.GetGuild(TextBox4.Text).GetTextChannel(TextBox5.Text).SendMessageAsync("", False, builder.Build())
- discord.GetGuild(TextBox4.Text).GetUser(userAccounts(usr)).ModifyAsync(Sub(u) u.Nickname = newNick)
- connectedUser.Remove(usr)
- connectedUserConfirm.Remove(usr)
- End If
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement