Guest User

Untitled

a guest
May 5th, 2019
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. # Work with Python 3.6
  2. # import dependencies
  3. import discord
  4. import sys
  5. from discord.ext import commands
  6.  
  7. # force python version
  8. #3#if sys.version_info[0] < 6:
  9. #3#    raise Exception("Python 3 or a more recent version is required.")
  10. print(sys.version)
  11.  
  12. # read token.txt as "file"
  13. # tokenff is temporary read
  14. with open('token.txt', 'r') as tokenff:
  15.     data = tokenff.read().replace('\n', '')
  16.  
  17. # set TOKEN >> under bots section
  18. TOKEN = data
  19.  
  20. # set command prefix
  21. #client = commands.Bot(command_prefix="!")
  22.  
  23. client = discord.Client()
  24.  
  25. # start events
  26. @client.event
  27. async def on_message(message):
  28.     # we do not want the bot to reply to itself
  29.     if message.author == client.user:
  30.         return
  31.  
  32.     if message.content.startswith('!hello'):
  33.         msg = 'Hello {0.author.mention}'.format(message)
  34.         await client.send_message(message.channel, msg)
  35.  
  36.  
  37.  
  38. # startup messages in console
  39. @client.event
  40. async def on_ready():
  41.     print('------------------------------')
  42.     print('Logged in as')
  43.     print(client.user.name)
  44.     print(client.user.id)
  45.     print('------------------------------')
  46.     print('Discord Python Version:')
  47.     print(discord.__version__)
  48.     print('------------------------------')
  49.  
  50.  
  51. #1#@client.event
  52. #1#async def on_message(message):
  53. #1#    # we do not want the bot to reply to itself
  54. #1#    if message.author == client.user:
  55. #1#        return
  56. #1#    
  57. #1#    await client.process_commands(message)
  58.  
  59.  
  60. #2#@client.command
  61. #2#async def hello(ctx):
  62. #2#    
  63. #2#    ctx.send("hello")
  64. #2#
  65.  
  66. # run with TOKEN
  67. client.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment