【发布时间】:2019-04-21 01:28:41
【问题描述】:
我正在构建一个不和谐的机器人,但我遇到了属性错误的问题,希望有人能纠正我。它应该运行,但它向我显示此错误:
AttributeError: 'str' 对象没有属性 'author'
import asyncio
import aiohttp
import json
from discord import Game
from discord.ext.commands import Bot
BOT_PREFIX = ('?', '!')
TOKEN = ""
client = Bot(command_prefix=BOT_PREFIX)
@client.command(name='8ball',
description="Answers a yes/no question.",
brief="Answers from the beyond.",
aliases=['eight_ball', 'eightball', '8-ball'],
pass_context=True)
async def eight_ball(context):
possible_responses = [
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
]
await client.process_commands(random.choice(possible_responses) + ", " + context.message.author.mention)
client.run(TOKEN)```
【问题讨论】:
-
context.message是一个字符串,不是你想的那样。 -
我该如何解决这个问题
标签: python python-3.x discord.py