我试图制作一个命令,将消息发送到指定的频道并得到以下错误
const manager = {
//stuff here
}
Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
答案 0 :(得分:1)
您不必将 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}")