我目前有一个命令的代码,该命令接受一个通道 ID,然后是一些文本消息作为输入。然后代码找到通道并在其上发送消息。然而,Discord 刚刚发布了一个新的线程功能,目前官方 Discord API docs 没有更新关于机器人如何与线程交互。那么,机器人如何向线程发送消息呢?请留下答案,因为 Discord 发布了新信息。这是我之前讨论过的代码:
@bot.command()
async def text(ctx, channel_id, *, msg):
channel = bot.get_channel(int(channel_id))
try:
await channel.send(ctx.message.attachments[0].url)
except IndexError:
pass
await channel.trigger_typing()
await channel.send(msg)