bot.py 830 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import discord
  2. import os
  3. import asyncio
  4. import command
  5. import time
  6. import sys
  7. PREFIX = ">"
  8. #reading private stuff from file
  9. #If you run this bot yourself you have to create this file yourself.
  10. client = discord.Client()
  11. @client.event
  12. async def on_message(message):
  13. # we do not want the bot to reply to itself
  14. if message.author == client.user:
  15. return
  16. if message.content.startswith(PREFIX):
  17. await command.handle_command(client, message)
  18. @client.event
  19. async def on_ready():
  20. print('Logged in as')
  21. print(client.user.name)
  22. print(client.user.id)
  23. print('------')
  24. command.servers.client = client
  25. await command.init_updater()
  26. #reading token from file
  27. dirname, filename = os.path.split(os.path.abspath(__file__))
  28. ref = open(dirname + "/private.ref", 'r')
  29. TOKEN = str.strip(ref.readline())
  30. ref.close()
  31. client.run(TOKEN)