首页 > 解决方案 > 如何在 discord.py 中获取 pin 消息

问题描述

我想在当前频道中获取最新的固定消息,但我不知道如何获取固定消息。如果你们知道如何获取最新的固定消息。

标签: pythondiscord.py

解决方案


您将需要使用 检索通道的所有引脚channel.pins(),如下面的代码所示。list假设频道有别针,这会给你一条消息。

pins = await ctx.channel.pins() # a list of all the channel's pins
await ctx.send(pins[0]) # sends all the information in the channel's first pin
await ctx.send(pins[0].content) # sends the content of the message. 
                                # An error will occur if there is no message content

可能在 cmd 中使用

文档


推荐阅读