使用 Pycord 在 Discord 中启动线程

Starting thread in Discord using Pycord

我正在尝试使用 Pycord 库启动线程。除了 official documentation,我找不到任何现实生活中的例子。

到目前为止,我 运行 变成 Error 400 Bad Request (error code: 20035): Guild Premium subscription level too low

我已经尝试了提到的解决方案 here,但到目前为止没有成功。

这是我当前的代码,知道我该如何处理它吗?

class MyClient(discord.Client):
    def __init__(self, *args, **kwargs):
        self.comments = kwargs.pop("comments")
        super().__init__(*args, **kwargs)

    async def on_ready(self):
        channel = self.get_channel(xxx)  # Your channel ID goes here
        for comment in comments:
            # await channel.send(comment['data']['author'])
            # await channel.create_thread(comment['data']['link_title'])

            await channel.create_thread(name="wop")

此外,我的机器人似乎拥有正确的权限,如下所示:

说明

根据错误 (Guild Premium subscription level too low),您的服务器没有得到足够的提升,无法使用私有线程,这是 pycord 中的默认设置。

您可以通过修改传递给 create_threadtype 参数来更改此行为,如下所示:

代码

from pycord.enums import ChannelType
class MyClient(discord.Client):
    def __init__(self, *args, **kwargs):
        self.comments = kwargs.pop("comments")
        super().__init__(*args, **kwargs)

    async def on_ready(self):
        channel = self.get_channel(xxx)  # Your channel ID goes here
        for comment in comments:
            # await channel.send(comment['data']['author'])
            # await channel.create_thread(comment['data']['link_title'])

            await channel.create_thread(name="wop", type=ChannelType.public_thread)

请注意,ChannelType 是从 pycord.enums

导入的

参考资料

ChannelType

create_thread

https://discord.com/developers/docs/resources/channel#start-thread-without-message

  • Creating a private thread requires the server to be boosted. The guild features will indicate if that is possible for the guild.