【发布时间】:2020-10-01 06:47:16
【问题描述】:
我正在开发我的不和谐机器人。 我正在下订单向特定房间发送消息,但我无法做到......这是我的代码:
@client.command(name='say', help='Dire un message à votre place')
@commands.has_permissions(send_messages=True, manage_messages=True)
async def say(ctx, message, channelid):
await client.wait_until_ready()
channel = client.get_channel(channelid)
embed = discord.Embed(title="Message", color=discord.Color.dark_red())
embed.add_field(name="Nouveau message de {}".format(ctx.message.author), value="{}".format(message))
embed.set_footer(text="{}".format(ctx.message.author))
await channel.send(embed=embed)
这是我在终端中遇到的错误。
Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send"
提前感谢您的回复。
PS : 我的机器人是法语的
【问题讨论】:
-
看起来
client.get_channel(channelid)找不到需要的频道,所以它返回None值。你确定channelid是正确的吗? -
我在 discord 上发送的消息是
c?say message 720347475361267843 -
请! ;)
标签: python discord.py