Discord Python 无法在“bot”中找到属性“event”

问题描述 投票:0回答:1

看看我的代码/ 这是输出: 回溯(最近一次调用最后一次): 文件“C:\Games\Coding ickets.py”,第 8 行,位于 @client.event ^^^^^^^^^^^^^ AttributeError:模块“discord.client”没有属性“event”

代码:

import discord
from discord.ext import commands

client = commands.bot

@client.event
async def on_ready():
    print("Bot is ready to execute action")

这里出了什么问题?

python discord bots
1个回答
0
投票

它是

commands.Bot
,你需要使用
command_prefix
参数来调用它。

from discord.ext import commands

client = commands.Bot(command_prefix='!')

@client.event
async def on_ready():
    print("Make something with the bot")

client.run('BOT_TOKEN')
© www.soinside.com 2019 - 2024. All rights reserved.