首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Pycord启动不和谐线程

使用Pycord启动不和谐线程
EN

Stack Overflow用户
提问于 2022-02-01 08:23:49
回答 1查看 1.2K关注 0票数 1

我正在尝试使用Pycord库启动一个线程。除了正式文件之外,我找不到任何真实的例子来说明这是怎么回事。

到目前为止,我正在遇到一个Error 400 Bad Request (error code: 20035): Guild Premium subscription level too low

我已经尝试过提到这里的解决方案,但到目前为止还没有成功。

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

代码语言:javascript
复制
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")

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-01 23:56:36

解释

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

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

代码

代码语言:javascript
复制
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

  • 创建私有线程需要提升服务器。公会功能将表明,如果这是可能的行会。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70937404

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档