Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. @client.command(pass_context=True)
  2. async def q(ctx):
  3. roles = ctx.message.author.roles
  4. rank = getRank(roles)
  5. channel = ctx.message.channel
  6. channelRank = getChannelRank(ctx.message.channel.id)
  7. if rank is not None and channelRank is not None and rank == channelRank:
  8. if ctx.message.author not in rankQueues[rank]["queue"]:
  9.  
  10. async with lock:
  11. rankQueues[rank]["queue"].append(ctx.message.author)
  12.  
  13. embed = discord.Embed()
  14.  
  15. embed.add_field(name="{} players are in the queue.".format(len(rankQueues[rank]["queue"])), value="{} has joined the queue. To join the queue, type .q.".format(ctx.message.author.mention))
  16. embed.colour = rankQueues[rank]["color"]
  17. await channel.send(embed=embed)
  18. player_check(ctx.message.author)
  19.  
  20. if len(rankQueues[rank]["queue"]) == 4:
  21. message = ""
  22. team1 = []
  23. team2 = []
  24. random.shuffle(rankQueues[rank]["queue"])
  25. for index, player in enumerate(rankQueues[rank]["queue"]):
  26. message += f"{player.mention} "
  27. if index < 2:
  28. team1.append(player)
  29. else:
  30. team2.append(player)
  31. await channel.send(message)
  32.  
  33. embed = discord.Embed()
  34. embed.add_field(name="Lobby {} is ready!".format(lobby_num[0]), value="You may now join the team channels.")
  35. embed.add_field(name="**Team 1**", value="{} {}".format(team1[0].mention, team1[1].mention), inline=False)
  36. embed.add_field(name="**Team 2**", value="{} {}".format(team2[0].mention, team2[1].mention), inline=False)
  37. embed.colour = rankQueues[rank]["color"]
  38. await channel.send(embed=embed)
  39. client.loop.create_task(create_lobby_voice(ctx.message.guild, rankQueues[rank]["parent"], lobby_num[0]))
  40. password = randint(1000, 9999)
  41. username = "{}{}{}{}".format(random.choice(string.ascii_letters), random.choice(string.ascii_letters), random.choice(string.ascii_letters), random.choice(string.ascii_letters))
  42. for index, player in enumerate(rankQueues[rank]["queue"]):
  43. embed = discord.Embed()
  44. if index == 0:
  45. embed.add_field(name="Create lobby {}!".format(lobby_num[0]), value="Use this info to create the lobby!")
  46. embed.add_field(name="**Username**", value="{}".format(username))
  47. embed.add_field(name="**Password**", value="{}".format(password))
  48. else:
  49. embed.add_field(name="Lobby {} info:".format(lobby_num[0]), value="Use this info when joining the lobby.")
  50. embed.add_field(name="**Username**", value="{}".format(username))
  51. embed.add_field(name="**Password**", value="{}".format(password))
  52. await player.send(embed=embed)
  53.  
  54.  
  55. queue = {
  56. "id": lobby_num[0],
  57. "queue": {
  58. "team1": team1,
  59. "team2": team2
  60. }
  61. }
  62.  
  63. lobby_num[0] = lobby_num[0] + 1
  64. rankQueues[rank]["progressQueues"].append(queue)
  65.  
  66. rankQueues[rank]["queue"] = []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement