Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Collections.Generic
- Imports System.Linq
- Imports System.Text
- Imports System.Threading.Tasks
- Imports Discord
- Imports Discord.Commands
- Public Class config
- Public Team_1 As String
- Public Team_2 As String
- Public currentmapsubmatches As mapsubmatches
- Public allmapsubmatches As mapsubmatches
- Public banned_1 As [String]
- Public banned_2 As [String]
- Public first_submatch As [String]
- Public first_map As [String]
- Public second_submatch As [String]
- Public second_map As [String]
- Public last_submatch As [String]
- Public last_map As [String]
- Public phase As Int32
- Public Sub New()
- Team_1 = ""
- Team_2 = ""
- banned_1 = ""
- banned_2 = ""
- first_map = ""
- first_submatch = ""
- second_map = ""
- second_submatch = ""
- last_map = ""
- last_submatch = ""
- phase = 0
- allmapsubmatches = New mapsubmatches
- currentmapsubmatches = New mapsubmatches
- End Sub
- End Class
- Public Class map
- Public name As String
- Public command As String
- End Class
- Public Class mapsubmatches
- Public Maps As New List(Of map)
- Public submatches As New List(Of String)
- Public Sub New()
- Dim Map1 As New map
- Map1.name = "91°"
- Map1.command = "91"
- Dim Map2 As New map
- Map2.name = "Artificial Intelligence"
- Map2.command = "artificial"
- Dim Map3 As New map
- Map3.name = "TrackStagram"
- Map3.command = "trackstagram"
- Dim Map4 As New map
- Map4.name = "Cozy"
- Map4.command = "cozy"
- Dim Map5 As New map
- Map5.name = "Austin"
- Map5.command = "austin"
- Maps.Add(Map1)
- Maps.Add(Map2)
- Maps.Add(Map3)
- Maps.Add(Map4)
- Maps.Add(Map5)
- Dim Submatch1 As String = "1v1&4v4"
- Dim Submatch2 As String = "2v2&3v3"
- Dim Submatch3 As String = "5v5"
- submatches.Add(Submatch1)
- submatches.Add(Submatch2)
- submatches.Add(Submatch3)
- End Sub
- End Class
- Public Class MyBot
- Private discord As DiscordClient
- Private mapsubmatches As New mapsubmatches
- Private ongoingbans As New Dictionary(Of String, config)
- ' 0 = PickBan inaktiv, 1= Ban gestartet, 2 = Team A hat die erste Map gebannt, 3 = Team B hat die zweite Map gebannt, 4 = Team A hat das erste Submatch ausgewählt, 5 = Team B hat die erste Map(für das asugewählte Submatch) ausgewählt, 6 = Team B hat das zweite Submatch ausgewählt, 7 = Team A hat die zweite Map ausgewählt
- Private Function remainingmapnames(current_maps As List(Of map)) As String
- Dim temp As String = ""
- For Each s As map In current_maps
- temp &= s.name & "; "
- Next
- Return temp.Remove(temp.Length - 2, 2)
- End Function
- Private Function remainingmapcommands(current_maps As List(Of map)) As String
- Dim temp As String = ""
- For Each s As map In current_maps
- temp &= s.command & "; "
- Next
- Return temp.Remove(temp.Length - 2, 2)
- End Function
- Private Function remainingsubmatches(current_submatches As List(Of String)) As String
- Dim temp As String = ""
- For Each s As String In current_submatches
- temp &= s & "; "
- Next
- Return temp.Remove(temp.Length - 2, 2)
- End Function
- Public Sub New()
- Dim temp1 As New DiscordConfigBuilder
- temp1.LogLevel = LogSeverity.Debug
- temp1.LogHandler = AddressOf Log
- discord = New DiscordClient(temp1)
- discord.UsingCommands(Function(x) As CommandServiceConfigBuilder
- x.PrefixChar = "!"c
- Return x
- End Function)
- discord.GetService(Of CommandService)().CreateCommand("bringbeer").[Do](Async Function(e)
- Await e.Channel.SendMessage("**Take a :Beer:** " + e.User.Name)
- End Function)
- discord.GetService(Of CommandService)().CreateCommand("pickban2").[Do](Async Function(e)
- If ongoingbans.ContainsKey(e.Channel.Name) Then
- Await e.Channel.SendMessage("There already is an Pick&ban started")
- Else
- Dim conf As New config
- Try
- Dim temps As String() = Split(e.Channel.Name, "_")
- conf.Team_1 = temps(0)
- conf.Team_2 = temps(1)
- Catch ex As Exception
- conf.Team_1 = "Team A"
- conf.Team_2 = "Team B"
- End Try
- conf.phase = 1
- ongoingbans.Add(e.Channel.Name, conf)
- Await e.Channel.SendMessage("**Welcome on the eXeS TC Pick&Ban phase** ! I'm softyBot, here to help you so your Pick&Ban phase goes smoothly. **Team A is gonna be the team with the best groupstage seed** and Team B the other one. You will have **3 minutes** of reflexion between every step of the phase." + System.Environment.NewLine + "The mappack used for this round is : **" + remainingmapnames(mapsubmatches.Maps) + "**." + System.Environment.NewLine + "Submatches used are : ** " + remainingsubmatches(mapsubmatches.submatches) + " **" + System.Environment.NewLine + System.Environment.NewLine + "To ban a map you will have to use the command : **!BAN Name of the map**, so for example : !BAN 91°. To pick a map or a submatche you will have to used : **!PICK Name of the map **or **!PICK 1v1 & 4v4 **." + System.Environment.NewLine + System.Environment.NewLine + "**Let the show begin !**" + System.Environment.NewLine + "**Team A **ban 1 map, please." + System.Environment.NewLine + System.Environment.NewLine + "**Possible commands:** !ban **" + remainingmapcommands(conf.currentmapsubmatches.Maps) + "**" + System.Environment.NewLine + "Team A: " + conf.Team_1 + System.Environment.NewLine + "Team B: " + conf.Team_2)
- End If
- End Function)
- discord.GetService(Of CommandService)().CreateCommand("stoppickban").[Do](Async Function(e)
- If ongoingbans.ContainsKey(e.Channel.Name) Then
- ongoingbans.Remove(e.Channel.Name)
- Await e.Channel.SendMessage("Currently running Pick&Ban was cancelled!")
- Else
- Await e.Channel.SendMessage("There is no urrently running Pick&Ban in this Channel")
- End If
- End Function)
- discord.GetService(Of CommandService)().CreateGroup("ban", Function(cgb) As CommandGroupBuilder
- For Each s As map In mapsubmatches.Maps
- cgb.CreateCommand(s.command).[Do](Async Function(e2)
- If ongoingbans.ContainsKey(e2.Channel.Name) Then
- Dim conf As New config
- ongoingbans.TryGetValue(e2.Channel.Name, conf)
- Select Case conf.phase
- Case 0
- Await e2.Channel.SendMessage("Currently there is no ongoing Pick&Ban")
- Exit Select
- Case 1
- conf.banned_1 = s.name
- conf.phase = 2
- conf.currentmapsubmatches.Maps.RemoveAll(Function(x) x.name = s.name)
- Await e2.Channel.SendMessage("**" + conf.Team_1 + "decides to ban " + s.name + ".**" + System.Environment.NewLine + conf.Team_2 + " ban 1 map, please." + System.Environment.NewLine + System.Environment.NewLine + "**Possible commands: **!ban **" + remainingmapcommands(conf.currentmapsubmatches.Maps) + "**")
- Exit Select
- Case 2
- If s.name = conf.banned_1 Then
- Await e2.Channel.SendMessage(conf.Team_1 + " already decided to ban " + s.name + ". Please choose a different map to ban")
- Else
- conf.banned_2 = s.name
- conf.phase = 3
- conf.currentmapsubmatches.Maps.RemoveAll(Function(x) x.name = s.name)
- Await e2.Channel.SendMessage("**" + conf.Team_2 + " decides to ban " + s.name + ".**" + System.Environment.NewLine + remainingmapnames(conf.currentmapsubmatches.Maps) + "are the chosen maps for this match." + System.Environment.NewLine + "You now need to pick submatches And the associating maps to them. " + conf.Team_1 + " pick the first submatch, please." + System.Environment.NewLine + System.Environment.NewLine + "**Possible commands:** !pick **" + remainingsubmatches(conf.currentmapsubmatches.submatches) + "**")
- End If
- Exit Select
- Case Else
- Await e2.Channel.SendMessage("The maps for this match already were banned!")
- Exit Select
- End Select
- Else
- Await e2.Channel.SendMessage("You need to start the pick&ban first!")
- End If
- End Function)
- Next
- Return cgb
- End Function)
- discord.GetService(Of CommandService)().CreateGroup("pick", Function(cgb) As CommandGroupBuilder
- For Each s As [String] In mapsubmatches.submatches
- cgb.CreateCommand(s).[Do](Async Function(e2)
- If ongoingbans.ContainsKey(e2.Channel.Name) Then
- Dim conf As New config
- ongoingbans.TryGetValue(e2.Channel.Name, conf)
- Select Case conf.phase
- Case Is < 3
- Await e2.Channel.SendMessage("You are not ready to pick maps and submatches yet")
- Exit Select
- Case 3
- conf.first_submatch = s
- conf.currentmapsubmatches.submatches.Remove(s)
- conf.phase = 4
- Await e2.Channel.SendMessage("**" + conf.Team_1 + " chose " + s + "** as the first submatch. " + conf.Team_2 + " please select the associating map!" + System.Environment.NewLine + System.Environment.NewLine + "**Possible commands: **!pick **" + remainingmapcommands(conf.currentmapsubmatches.Maps) + "**")
- Exit Select
- Case 4
- Await e2.Channel.SendMessage("You need to pick a map, not a submatch!")
- Exit Select
- Case 5
- If conf.currentmapsubmatches.submatches.Contains(s) Then
- conf.second_submatch = s
- conf.currentmapsubmatches.submatches.Remove(s)
- conf.phase = 6
- Await e2.Channel.SendMessage("**" + conf.Team_2 + " chose " + s + "** as the second submatch. " + conf.Team_1 + " please select the associating map." + System.Environment.NewLine + System.Environment.NewLine + "**Possible commands: **!pick **" + remainingmapcommands(conf.currentmapsubmatches.Maps) + "**")
- Else
- Await e2.Channel.SendMessage("You can't select this submatch.")
- End If
- Exit Select
- Case 6
- Await e2.Channel.SendMessage("You need to pick a map, not a submatch!")
- Exit Select
- Case Else
- Await e2.Channel.SendMessage("The maps for this match already were banned!")
- Exit Select
- End Select
- Else
- Await e2.Channel.SendMessage("You need to start the pick&ban first!")
- End If
- End Function)
- Next
- For Each s As map In mapsubmatches.Maps
- cgb.CreateCommand(s.command).[Do](Async Function(e2)
- If ongoingbans.ContainsKey(e2.Channel.Name) Then
- Dim conf As New config
- ongoingbans.TryGetValue(e2.Channel.Name, conf)
- Select Case conf.phase
- Case Is < 3
- Await e2.Channel.SendMessage("You are not ready to pick maps and submatches yet")
- Exit Select
- Case 3
- Await e2.Channel.SendMessage("You need to pick a submatch, not a map!")
- Exit Select
- Case 4
- If conf.currentmapsubmatches.Maps.Exists(Function(x) x.name = s.name) Then
- conf.first_map = s.name
- conf.currentmapsubmatches.Maps.RemoveAll(Function(x) x.name = s.name)
- conf.phase = 5
- Await e2.Channel.SendMessage("**" + conf.Team_2 + " chose " + s.name + "** as first Map. Please also select the second submatch " + conf.Team_2 + "." + System.Environment.NewLine + System.Environment.NewLine + "**Possible commands: **!pick **" + remainingsubmatches(conf.currentmapsubmatches.submatches) + "**")
- Else
- Await e2.Channel.SendMessage("You can't pick this map!")
- End If
- Exit Select
- Case 5
- Await e2.Channel.SendMessage("You need to pick a submatch, not a map!")
- Exit Select
- Case 6
- If conf.currentmapsubmatches.Maps.Exists(Function(x) x.name = s.name) Then
- conf.second_map = s.name
- conf.currentmapsubmatches.Maps.RemoveAll(Function(x) x.name = s.name)
- conf.last_map = remainingmapnames(conf.currentmapsubmatches.Maps)
- conf.last_submatch = remainingsubmatches(conf.currentmapsubmatches.submatches)
- conf.phase = 7
- Await e2.Channel.SendMessage("**Gratualtions!** You completed the pick&ban and can now play your match! This will be your matchshedule:" + System.Environment.NewLine + System.Environment.NewLine + "First map: " + conf.first_map + " | " + conf.first_submatch + System.Environment.NewLine + "Second map: " + conf.second_map + " | " + conf.second_submatch + System.Environment.NewLine + "Last map: " + conf.last_map + " | " + conf.last_submatch + System.Environment.NewLine + "**GLHF to both Teams!**")
- ongoingbans.Remove(e2.Channel.Name)
- Else
- Await e2.Channel.SendMessage("You can't pick this map!")
- End If
- Exit Select
- Case Else
- Await e2.Channel.SendMessage("The maps for this match already were banned!")
- Exit Select
- End Select
- Else
- Await e2.Channel.SendMessage("You need to start the pick&ban first!")
- End If
- End Function)
- Next
- Return cgb
- End Function)
- discord.ExecuteAndWait(Async Function()
- Await discord.Connect("I won't show you this part ofc =P", TokenType.Bot)
- End Function)
- End Sub
- Private Sub Log(sender As Object, e As LogMessageEventArgs)
- Console.WriteLine(e.Message)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement