【问题标题】:AttributeError: module 'discord.client' has no attribute 'event'AttributeError:模块“discord.client”没有属性“事件”
【发布时间】: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!")

【问题讨论】:

    标签: python discord bots


    【解决方案1】:

    试试

    client = discord.Client()
    

    这应该可以工作

    【讨论】:

      猜你喜欢
      • 2019-01-14
      • 2018-04-14
      • 2019-02-18
      • 1970-01-01
      • 2020-01-01
      • 1970-01-01
      • 2019-07-20
      • 2021-11-05
      相关资源
      最近更新 更多