簡體   English   中英

使用 discord.py 獲取頻道中的所有固定消息

[英]using discord.py to get all pinned messages in a channel to

我創建了一個 discord 機器人,它使用固定消息來顯示信息,因此為避免混亂,我嘗試添加一個單獨的 function 以擺脫所有固定消息。 我已經想出了如何取消固定消息(unpin()),所以我試圖獲取所有固定的消息,以便我可以遍歷它們並取消固定它們。 我發現有人說要使用 client.pins(channel) 和 .pins_from(channel) 但它們都返回無屬性錯誤,所以我想知道我做錯了什么? 謝謝你

使用await TextChannel.pins()獲取所有固定消息

@bot.command()
async def unpinall(ctx):
    pins = await ctx.channel.pins()
    for i in pins:
        await i.unpin()
    await ctx.send("Unpinned all pinned messages!")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM