Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Work with Python 3.6
- # import dependencies
- import discord
- import sys
- from discord.ext import commands
- # force python version
- #3#if sys.version_info[0] < 6:
- #3# raise Exception("Python 3 or a more recent version is required.")
- print(sys.version)
- # read token.txt as "file"
- # tokenff is temporary read
- with open('token.txt', 'r') as tokenff:
- data = tokenff.read().replace('\n', '')
- # set TOKEN >> under bots section
- TOKEN = data
- # set command prefix
- #client = commands.Bot(command_prefix="!")
- client = discord.Client()
- # start events
- @client.event
- async def on_message(message):
- # we do not want the bot to reply to itself
- if message.author == client.user:
- return
- if message.content.startswith('!hello'):
- msg = 'Hello {0.author.mention}'.format(message)
- await client.send_message(message.channel, msg)
- # startup messages in console
- @client.event
- async def on_ready():
- print('------------------------------')
- print('Logged in as')
- print(client.user.name)
- print(client.user.id)
- print('------------------------------')
- print('Discord Python Version:')
- print(discord.__version__)
- print('------------------------------')
- #1#@client.event
- #1#async def on_message(message):
- #1# # we do not want the bot to reply to itself
- #1# if message.author == client.user:
- #1# return
- #1#
- #1# await client.process_commands(message)
- #2#@client.command
- #2#async def hello(ctx):
- #2#
- #2# ctx.send("hello")
- #2#
- # run with TOKEN
- client.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment