discord.ext.command.errors.CommandInvokeError: 命令引发异常: AttributeError: 'Events'对象没有属性 'get_channe



我想让它在我的机器人启动时向某些聊天发送消息。正常通电后,一切都很好,当我已经使用了一个特殊的重新启动命令时,就会出现这个错误。这是代码:

@client.event
async def on_ready():
changeStatus.start()
kvuqqs = client.get_channel(906998823187017728)
librar = client.get_channel(906168716197232660)
await kvuqqs.send('Айоу! Бот был включен. nК сожалению, на данный момент обновлений нет. n`l.хелп`')
await librar.send(embed=discord.Embed(title='Бот был включен!', description='Версия бота на данный момент: 2.0.1.', color=random.choice(colors)))

还有一个完整的错误:

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Events' object has no attribute 'get_channel'

bruh要从id获得通道,你需要一个公会

示例:-

guild = client.get_guild(ID)
channel = guild.get_channel(ID)

通过id获得渠道或公会是的特权意图

在你的机器人中添加此代码(如果你还没有(

intents = discord.Intents().all()
client = commands.Bot(command_prefix='prefix', intents=intents)

你必须在Discord Dev Portal 中打开这些意图

你可以在这里阅读更多关于意图的信息:-https://discordpy.readthedocs.io/en/stable/intents.html

相关内容

最新更新