python - 如何在 discord.py 中获取 pin 消息
问题描述
我想在当前频道中获取最新的固定消息,但我不知道如何获取固定消息。如果你们知道如何获取最新的固定消息。
解决方案
您将需要使用 检索通道的所有引脚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
文档:
推荐阅读
- node.js - why sometimes npm install is not working on mac?
- r - 如何在 R 中的 ifelse 语句中使用 or ?
- javascript - 带有循环的奇怪的Javascript变量函数范围
- python - 如果 x 不是类绑定或实例绑定变量,self.x 如何工作?
- javascript - 在上传的图像上绘制矩形
- python - 如何访问嵌套在dict中的元组切片?
- r - 积分的最大值
- javascript - 在这种情况下如何避免声明全局变量?
- reactjs - TypeError: "name" is read-only
- r - 无法在每个数据文件中获得完全观察到的案例