Advertisement
szymski

Untitled

Feb 22nd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. import discord
  2. import asyncio
  3.  
  4. client = discord.Client()
  5. server = None
  6. lobbyChannel = None
  7.  
  8. def init():
  9. print("Starting the bot")
  10. global client
  11. client.run("XXX")
  12.  
  13. @client.event
  14. async def on_ready():
  15. global client, server, lobbyChannel
  16.  
  17. print('Logged in as')
  18. print(client.user.name)
  19. print(client.user.id)
  20. print('------')
  21.  
  22. lobbyChannel = client.get_channel("234378707853246464") #client.get_channel("234378707853246464")
  23. server = client.get_server("234365566608080896")
  24.  
  25. client.loop.create_task(handle_lobby())
  26.  
  27. @client.event
  28. async def on_member_join(member):
  29. await client.send_message(lobbyChannel, "Witaj {}! Napisz tutaj swój typ osobowości, a zostanie Ci przydzielona ranga.".format(member.mention))
  30.  
  31. @asyncio.coroutine
  32. async def handle_lobby():
  33. valid_types = [ "ENFJ", "ENFP", "ENTJ", "ENTP", "ESFJ", "ESFP", "ESTJ", "ESTP", "INFJ", "INFP", "INTJ", "INTP", "ISFJ", "ISFP", "ISTJ", "ISTP" ]
  34. type_roles = { }
  35.  
  36. await client.wait_until_ready()
  37.  
  38. for role in server.roles:
  39. if role.name.upper() in valid_types:
  40. type_roles[role.name.upper()] = role
  41.  
  42. # await client.send_message(lobbyChannel, "Bot został uruchomiony!")
  43.  
  44. while not client.is_closed:
  45. msg = await client.wait_for_message(channel=lobbyChannel)
  46.  
  47. if msg.author == client.user:
  48. continue
  49.  
  50. for type_str in valid_types:
  51. if type_str in msg.content.upper():
  52. await client.remove_roles(msg.author, *type_roles.values())
  53. await client.add_roles(msg.author, type_roles[type_str])
  54.  
  55. await client.send_message(lobbyChannel, msg.author.mention + ", od teraz twój typ to **" + type_str + "**")
  56.  
  57. break
  58.  
  59.  
  60. init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement