discord.py 中的属性错误
AttributeError in discord.py
我正在尝试构建在任何客户端创建频道时打印消息的机器人。
我正在使用 discord.py 版本 1.2.3
import discord
import discord.ext
client = discord.Client()
@client.event
async def channel_create(channel):
if discord.on_guild_channel_create():
await print('the channel has been create ')
return
client.run('TOKEN')
当我 运行 它时,我得到这个错误:
AttributeError: module 'discord' has no attribute 'on_guild_channel_create'
有什么解决这个问题的建议吗?
基于 API reference,我会说您的函数需要覆盖 on_guild_channel_create()
而不是将其作为另一个函数的一部分调用。
import discord
import discord.ext
client = discord.Client()
@client.event
async def on_guild_channel_create(channel):
await print('the channel has been create ')
return
client.run('TOKEN')
我正在尝试构建在任何客户端创建频道时打印消息的机器人。 我正在使用 discord.py 版本 1.2.3
import discord
import discord.ext
client = discord.Client()
@client.event
async def channel_create(channel):
if discord.on_guild_channel_create():
await print('the channel has been create ')
return
client.run('TOKEN')
当我 运行 它时,我得到这个错误:
AttributeError: module 'discord' has no attribute 'on_guild_channel_create'
有什么解决这个问题的建议吗?
基于 API reference,我会说您的函数需要覆盖 on_guild_channel_create()
而不是将其作为另一个函数的一部分调用。
import discord
import discord.ext
client = discord.Client()
@client.event
async def on_guild_channel_create(channel):
await print('the channel has been create ')
return
client.run('TOKEN')