【发布时间】:2021-01-31 10:11:43
【问题描述】:
所以我正在关注有关创建 Discord 机器人的 Python Discord 教程。当我运行代码时,它说“AttributeError:模块'discord.client'没有属性'event'”。当我在网上搜索时,大多数答案都令人困惑。我现在正在使用 repl.it 并在 Pycharm 上进行尝试。两者都以相同的错误结束。
仅供参考:我删除了client.run,因此不会显示令牌。
import discord
import os
client = discord.client
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("%Wilson"):
await message.send.channel("I can ping you!")
【问题讨论】: