Advertisement
Guest User

10 man discord bot :)

a guest
Feb 28th, 2016
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.98 KB | None | 0 0
  1. import discord
  2.  
  3. client = discord.Client()
  4. email = "clearskypony@gmail.com"
  5. password = "mlpdashie1"
  6.  
  7. numofplayers = 10
  8.  
  9. @client.event
  10. async def on_message(message):
  11.     entered = []
  12.     if message.author == client.user:
  13.         return
  14.    
  15.     if message.content.startswith("!hello"):
  16.         msg = "Hello {0.author.mention}".format(message)
  17.         await client.send_message(message.channel, msg)
  18.  
  19.     if message.content.startswith("!10man"):
  20.         await client.send_message(message.channel, "Starting 10 man:\nTo enter, type '!enter'\nTo leave type '!leave'\nTo list the current users in the 10 man, type '!listusers'")
  21.         while len(entered) <= numofplayers:
  22.             if len(entered) == numofplayers:
  23.                 msg = "Starting 10 man with the following users: ".format(message)
  24.                 await client.send_message(message.channel, msg)
  25.                 x = 0
  26.                 while x < numofplayers:
  27.                     username = (entered[x])
  28.                     await client.send_message(message.channel, username)
  29.                     x += 1
  30.                 entered = []
  31.                 return
  32.             else:
  33.                 messageobj = await client.wait_for_message()
  34.                 content = messageobj.content
  35.                 author = messageobj.author
  36.                 author = str(author)
  37.                 if content.startswith("!enter"):
  38.                     if any(author in s for s in entered):
  39.                         msg = "Cannot add {0.author.mention} to 10 man, because {0.author.mention} is already a part of the 10 man".format(message)
  40.                         await client.send_message(message.channel, msg)
  41.                     else:
  42.                         entered.append(author)
  43.                         msg = "Entered {0.author.mention} to the 10 man, to leave type '!leave'".format(message)
  44.                         await client.send_message(message.channel, msg)
  45.                 if content.startswith("!leave"):
  46.                     if any(author in s for s in entered):
  47.                         entered.remove(author)
  48.                         msg = "Removed {0.author.mention} from the 10 man".format(message)
  49.                         await client.send_message(message.channel, msg)
  50.                     else:
  51.                         msg = "Cannot remove {0.author.mention} from the 10 man, because {0.author.mention} is not in the 10 man".format(message)
  52.                         await client.send_message(message.channel, msg)
  53.                 if content.startswith("!listusers"):
  54.                     x = 0
  55.                     await client.send_message(message.channel, "Current users in 10 man: ")
  56.                     while x < len(entered):
  57.                         username = entered[x]
  58.                         await client.send_message(message.channel, username)
  59.                         x += 1
  60.  
  61.  
  62. @client.event
  63. async def on_ready():
  64.     print('Logged in as')
  65.     print(client.user.name)
  66.     print(client.user.id)
  67.  
  68. client.run(email, password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement