AttributeError:'str'对象没有属性'channel'是我得到的错误。我一直在环顾四周,答案仍然不清楚。该代码以前可以工作,但现在不行。我认为我没有对channel属性进行任何更改。
client = discord.Client()
@client.event
async def on_message(message):
if 'SJAY' in u:
message = '{0.author.mention}, Did you know Sjay is a God?'.format(message)
await client.send_message(message.channel, message)
client.loop.create_task(change_stat())
client.run(TOKEN)
答案 0 :(得分:0)
那是因为在使用它之前,您已将其值更改为字符串。进行以下更改将解决此问题:
client = discord.Client()
@client.event
async def on_message(message):
if 'SJAY' in u:
msg = '{0.author.mention}, Did you know Sjay is a God?'.format(message)
await client.send_message(message.channel, msg)
client.loop.create_task(change_stat())
client.run(TOKEN)