如何在 Discord 线程中发送消息?

Sha*_*rar 1 python discord.py

所以我需要在不和谐线程中创建和发送消息。我已经能够创建线程,但无法在其中发送消息。我正在使用 Discord.py 库(v2.0 支持线程)。

await ctx.channel.create_thread(name="Thread" , type=discord.ChannelType.public_thread )
Run Code Online (Sandbox Code Playgroud)

这就是我用来创建线程的东西。我不知道如何在其中发送消息。谢谢。

3nw*_*nws 5

create_thread()返回创建的线程,因此您可以从中调用send()

thread = await ctx.channel.create_thread(name="Thread" , type=discord.ChannelType.public_thread )
await thread.send("This message is sent to the created thread!")
Run Code Online (Sandbox Code Playgroud)