import discord
TOKEN = 'insert bot token here'
client = discord.Client()
@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('sam'):
msg = 'what {0.author.mention}'.format(message)
await client.send_message(message.channel, msg)
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run(TOKEN)
这就是我尝试运行它时发生的事情。
我正在使用Python 3.5,Pycharm,pip 18.1,virtualenv和最新版本的discord。我将该机器人作为应用程序,并且正确地复制了令牌。