python - 如果 channel 是私有(private)的,我怎么能得到 "check"呢?

标签 python python-3.x discord discord.py

如何在discord.py重写中“检查” channel 是否是私有(private)的, 我什至看到了类似的问题,但答案不起作用:<

最佳答案

检查 channel 是否是 PrivateChannel 的实例抽象基类:

from discord.abc import PrivateChannel
from discord.ext.commands import Bot    

bot = Bot(command_prefix='!')

@bot.command()
async def isprivate(ctx):
    await ctx.send(isinstance(ctx.channel, PrivateChannel))

bot.run("token")

关于python - 如果 channel 是私有(private)的,我怎么能得到 "check"呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52789414/

相关文章:

python - Python 中的双哈希 SHA256

python - 从可能使用 session ID 的安全 URL 中抓取页面

python - 在python中模拟函数的局部变量

javascript - 语法错误: Unexpected end of input Discord Bot

javascript - 如何根据操作码分离捕获的错误 (discord.js)

python - “元组”对象不可调用

python-3.x - 使用 matplotlib 堆积条形图

python - 在这种情况下,为什么 read_csv skiprows 值需要低于应有的值?

python - 如何对齐 QGraphicsTextItem 的网格?

javascript - Discord.js 不收集用户的 DM