首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PYCord如何通过视图获取消息?

PYCord如何通过视图获取消息?
EN

Stack Overflow用户
提问于 2022-05-21 19:19:59
回答 1查看 244关注 0票数 0

https://media.discordapp.net/attachments/977648291770667010/977648292206903336/unknown.png

正如您在屏幕截图中所看到的,有一个关于在官方PyCord网站超时到期时如何编辑消息内容的解释。

但正如你在这张截图中所看到的:https://media.discordapp.net/attachments/977648291770667010/977648292655677440/unknown.png

PyCharm说没有所谓的“消息”字段。

调试时会出现相同的错误:

https://media.discordapp.net/attachments/977648291770667010/977651067007426670/unknown.png?width=1200&height=123

这是我的代码:

代码语言:javascript
复制
    class UIAgreement(View):

    def __init__(self, client: Stragate):
        super().__init__(timeout=10)
        self.client = client

    async def on_timeout(self):

        self.disable_all_items()

        await self.message.edit(content="You took too long! Try again.", view=self)

    @button(label="Accept", style=ButtonStyle.success, emoji="")
    async def accept_callback(self, event_button: Button, event_interaction: Interaction):

        cursor = self.client.database.cursor()
        cursor.execute(f"SELECT * FROM profiles WHERE id={event_interaction.user.id} LIMIT 1")

        if not cursor.fetchone():
            cursor = self.client.database.cursor()

            cursor.execute("INSERT INTO profiles (id, full_name, job, country, description, thumbnail, "
                           "gender) VALUES (%s, %s, DEFAULT, DEFAULT, DEFAULT, %s, DEFAULT)",
                           (
                               event_interaction.user.id,
                               event_interaction.user.display_name,
                               "https://media.discordapp.net/attachments/976061052548694036"
                               "/977291014047936552/default.jpg"
                           ))
            self.client.database.commit()

            await event_interaction.user.send(embed=Embed(
                title="Successfully registered!",
                description="Please use the 'start' command again."
            ))```


  [1]: https://i.stack.imgur.com/ymKyQ.png
EN

回答 1

Stack Overflow用户

发布于 2022-05-21 19:42:37

我学到了"Message“字段,这是我需要在范围之外设置的字段。他们在不和谐的服务器上就是这么说的。我想指南有点过时了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72332598

复制
相关文章

相似问题

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