Python Discord.py通道“;你好”;找不到
我正在尝试为我的机器人创建一个“echo”命令,下面是我的代码Python Discord.py通道“;你好”;找不到,python,discord.py,Python,Discord.py,我正在尝试为我的机器人创建一个“echo”命令,下面是我的代码 @bot.command(name="echo", help="says something") async def echo(ctx, channel : None, *, text : str): if (message.author.bot): return if channel == None: # if a channel is not
@bot.command(name="echo", help="says something")
async def echo(ctx, channel : None, *, text : str):
if (message.author.bot):
return
if channel == None:
# if a channel is not specified, send in the same channel where the command was called
ctx.send(text)
else:
channel.send(text)
但当我键入“!echo hello”时,我出现了以下错误:
raise ChannelNotFound(argument)
discord.ext.commands.errors.ChannelNotFound: Channel "hello" not found.
什么???“频道”不应该是可选的吗?我该如何解决这个问题呢?问题是,你给机器人一个字符串
hello
,它想从中找到频道
Channel也是它自己的类,所以您必须构建一个搜索该通道的函数(discord.utils.get,我想)
我想你想要的是切换描述和频道,这样你就不必首先进入频道。问题是,你给机器人一个字符串
hello
,它想从中找到频道
Channel也是它自己的类,所以您必须构建一个搜索该通道的函数(discord.utils.get,我想)
我想你想要的是切换描述和频道,这样你就不必首先进入频道。我已经修好了,谢谢!哦,好的,你很好。我已经修好了,谢谢!哦,好的,不客气