问题描述
我目前正试图让一个机器人工作,但我陷入困境,想知道是否有人可以提供帮助:
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
#@bot.event
async def on_message(message):
# Deletes the command from the channel
if message.content.startswith(!)
await message.delete()
await bot.process_commands(message)
client.run('Client/////key')
我得到的输出是:
jeff@Bot-Host:~/Command Destroyer/Command-Destroyer$ python3 CD.py
File "CD.py",line 12
if message.content.startswith(!)
^
SyntaxError: invalid Syntax
解决方法
将第12行更改为if message.content.startswith('!'):
我相信您只需要将!
用引号引起来即可,例如:
if message.content.startswith('!'):
startswith
需要一个字符串作为第一个参数。
我相信您必须在if语句后加一个冒号...希望能有所帮助..谢谢