Discord.py 命令引发异常:AttributeError:';非类型';对象没有属性';发送';
我试图发出一个命令,将消息发送到指定的通道,并得到以下错误Discord.py 命令引发异常:AttributeError:';非类型';对象没有属性';发送';,discord.py,Discord.py,我试图发出一个命令,将消息发送到指定的通道,并得到以下错误 命令引发了异常:AttributeError:'NoneType'对象没有属性'send' @client.command(name="chmsg") async def _chmsg(ctx): def check(msg): return msg.author == ctx.author and \ msg.channel == ctx.channel
命令引发了异常:AttributeError:'NoneType'对象没有属性'send'
@client.command(name="chmsg")
async def _chmsg(ctx):
def check(msg):
return msg.author == ctx.author and \
msg.channel == ctx.channel
await ctx.send("Message")
mestoc = await client.wait_for("message", check=check)
await ctx.send("Channel id")
chasend = await client.wait_for("message", check=check)
mestoch = str(mestoc.content)
cha = str(chasend.content)
channel = client.get_channel(cha)
await channel.send(f"{mestoch}")
mestoc.content
转换为字符串,因为它已经是字符串了
cha
作为一个整数,而不是字符串,这样才能获得频道
@client.command(name="chmsg")
async def _chmsg(ctx):
def check(msg):
return msg.author == ctx.author and \
msg.channel == ctx.channel
await ctx.send("Message")
mestoc = await client.wait_for("message", check=check)
await ctx.send("Channel ID")
chasend = await client.wait_for("message", check=check)
mestoch = mestoc.content
cha = int(chasend.content)
channel = client.get_channel(cha)
await channel.send(f"{mestoch}")
对于这么简单的命令来说,这看起来太复杂了。您只是在寻找一个命令,该命令将某些内容发送到某个通道吗?