【发布时间】:2019-03-18 06:26:59
【问题描述】:
如何在 discord.py 重写中“检查”频道是否为私有, 我什至看到了一个类似的问题,但答案不起作用:
【问题讨论】:
标签: python python-3.x discord discord.py discord.py-rewrite
如何在 discord.py 重写中“检查”频道是否为私有, 我什至看到了一个类似的问题,但答案不起作用:
【问题讨论】:
标签: python python-3.x discord discord.py discord.py-rewrite
检查通道是否是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")
【讨论】:
我遇到了同样的问题并像这样解决它。 :)
@bot.event
async def on_message(message):
if str(message.channel.type) == "private":
print("message is privat...")
else:
print("message is not private...")
【讨论】: