SHARE
TWEET

Untitled

a guest Apr 22nd, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import discord
  2. import datetime
  3. import os
  4. import json
  5. TOKEN = 'NTY2NzIzNjI2NDA2MTE3Mzg2.XLfuhQ.Q5OGelMS2VbR97Jf5XkzWAzw96c'
  6. server_id = 566723507925417990
  7. client = discord.Client()
  8. date_time = datetime.datetime.now()
  9. channels = ["bot-commands"]
  10. admin_users = ['AuraBoom#2712']
  11.  
  12. @client.event
  13. async def on_message(message):
  14.     #Logs commands TIME:USER:COMMAND
  15.     def output(command):
  16.         now = datetime.datetime.now()
  17.         time = now.strftime('%e/%m/%y %H:%M')
  18.         print(str(time) + ':' + str(message.author) + ' ran the command ' + command)
  19.         commandlog(str(time) + ':' + str(message.author) + ' ran the command ' + command + "\n")
  20.        
  21.     def commandlog(log):
  22.         with open('commandloglist.txt', 'a+') as file:
  23.             file.write(log)
  24.    
  25.     #Commands
  26.     id = client.get_guild(server_id)
  27.  
  28.     #Admin (Works)
  29.     if str(message.channel) in channels and str(message.author) in admin_users:
  30.         if message.content.startswith("!admin"):
  31.             await message.channel.send("You are an admin")
  32.             output('!admin')
  33.  
  34.     #Hello (Works)
  35.     if str(message.channel) in channels:
  36.         if message.content.startswith("!hello"):
  37.             await message.channel.send('Hello')
  38.             output('!hello')
  39.    
  40.     #Members (Works)
  41.     if str(message.channel) in channels:
  42.         if message.content.startswith("!members"):
  43.             await message.channel.send(f"""There are {id.member_count} members""")
  44.             output('!members')
  45.  
  46.     #Purge (Works)
  47.     if str(message.author) in admin_users:
  48.         if message.content.startswith("!purge"):
  49.             output("!purge")
  50.        
  51.  
  52.             split_purge = message.content.split(' ')
  53.             amount = int(split_purge[1])
  54.             channel = message.channel
  55.  
  56.             if len(split_purge) < 2:
  57.                 return
  58.        
  59.  
  60.             if len(split_purge) == 2:
  61.                 await channel.purge(limit=amount)
  62.    
  63.    
  64.     #Give role (Not working)
  65.     if str(message.channel) in channels:
  66.         if message.content.startswith("!userrole"):
  67.             user_role = None
  68.                 for role in guild.roles:
  69.                     if role == 'User':
  70.                         user_role = role
  71.                         break
  72.         await message.author.add_roles(roles=[user_role])
  73.  
  74. client.run(TOKEN)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top