【发布时间】:2018-04-27 04:07:22
【问题描述】:
以前从未在 python 中编码,但刚刚开始,并且在创建不和谐机器人时完全出错。不确定代码有什么问题,但它看起来不像是最后一行。
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
Client = discord.client ()
bot_prefix = "!b"
client = commands.Bot (command_prefix=bot_prefix)
@client.event
async def on_ready () :
print("With Bepis")
@client.command(pass_context=true)
async def on_message(ctx:await client.say ("bepis")
if message.content == "bepis"
@client.send_message (message.channel, "**BEPIS**")
@client.run ("censored token")
是的,我知道我的机器人会变得愚蠢。我只是将它用作更官方机器人的测试。非常感谢您的帮助。
【问题讨论】:
-
可以分享一下错误和回溯吗?
-
最后一行是没有函数的函数装饰。那是不合法的,就像刚刚说
2 +并在此处结束的程序不合法一样。但是完全不清楚您想要在那里做什么,这使得在没有更多信息的情况下很难告诉您如何修复它。 -
算上你的括号。这里少了一个:
async def on_message(ctx:await client.say ("bepis").
标签: python syntax-error bots eof discord