Guest User

Untitled

a guest
May 19th, 2019
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. import discord
  2. import time
  3. import asyncio
  4.  
  5. #id = 576935257941475338
  6. messages = joined = 0
  7.  
  8.  
  9. def read_token():
  10. with open("token.txt", "r") as f:
  11. lines = f.readlines()
  12. return lines[0].strip()
  13.  
  14. token = read_token()
  15.  
  16. client = discord.Client()
  17.  
  18. async def update_stats():
  19. await client.wait_until_ready()
  20. global messages, joined
  21.  
  22. while not client.is_closed():
  23. try:
  24. with open("stats.txt", "a") as f:
  25. f.write(f"TIME: {int(time.time())}, MESSAGES: {messages}, MEM JOINED: {joined}\n")
  26.  
  27. messages = 0
  28. joined = 0
  29.  
  30. await asyncio.sleep(60)
  31. except Exception as e:
  32. print(e)
  33. await asyncio.sleep(60)
  34.  
  35. @client.event
  36. async def on_member_join(member):
  37. global joined
  38. joined += 1
  39.  
  40. for channel in member.server.channels:
  41. if str(channel) == "welcome":
  42. await client.send_message(f"""`Welcome to FS, {member.mention}""")
  43.  
  44. @client.event
  45. async def on_message(message):
  46. global messages
  47. messages += 1
  48.  
  49. id = client.get_guild(576935257941475338)
  50. channels = ["bot-spam", "entry-application"]
  51.  
  52. if str(message.channel) in channels:
  53. if message.content.find("db!hello") != -1:
  54. await message.channel.send("`Hi!`")
  55. elif message.content == "db!users":
  56. await message.channel.send(f"""`# of members: {id.member_count}`""")
  57. elif message.content == "db!logmein":
  58. role = discord.utils.get(message.guild.roles, name="MEMBER")
  59. await message.author.add_roles(role)
  60. await message.channel.send(f"""`You have been logged into the server. Thank you.`""")
  61. asyncio.sleep(5)
  62. await message.delete()
  63.  
  64. client.loop.create_task(update_stats())
  65.  
  66. client.run(token)
Advertisement
Add Comment
Please, Sign In to add comment