簡體   English   中英

檢查是否允許機器人在頻道中發送和讀取消息 discord.py

[英]Checking if bot is permitted to send and read messages in a channel discord.py

如何檢查是否允許我的機器人在特定頻道中發送和閱讀消息? 我現在的代碼是:

channel = client.get_channel('''channel id''')
print(channel.permissions_for(client.user))

但由此產生的錯誤是在 discord 的 abc.py 部分,它說:

print(channel.permissions_for(client.user))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/channel.py", line 146, in permissions_for
    base = super().permissions_for(member)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 486, in permissions_for
    roles = member._roles
AttributeError: 'ClientUser' object has no attribute '_roles'

即使機器人確實具有“機器人”角色。 任何輸入將不勝感激。 謝謝!

我建議您完整、清楚地閱讀[has_permission]文檔和[permission_property]
它會回答你的問題!

暫無
暫無

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

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