Python 检查消息是否由DM(discord.py)中的用户发送,然后将其消息从直接消息发送到特定通道? msg_dump_channel=1234 @机器人事件 _消息上的异步定义(消息:discord.message): 通道=bot.get\u通道(msg\u dump\u通道) 如果str(message.author)=“用户”: 等待频道发送(消息内容) 等待bot.process_命令(消息)
这是我的代码,我知道DMs没有公会,那么如何为DM编写公会呢?对象有一个属性,可以用于检查:Python 检查消息是否由DM(discord.py)中的用户发送,然后将其消息从直接消息发送到特定通道? msg_dump_channel=1234 @机器人事件 _消息上的异步定义(消息:discord.message): 通道=bot.get\u通道(msg\u dump\u通道) 如果str(message.author)=“用户”: 等待频道发送(消息内容) 等待bot.process_命令(消息),python,python-3.x,discord.py,Python,Python 3.x,Discord.py,这是我的代码,我知道DMs没有公会,那么如何为DM编写公会呢?对象有一个属性,可以用于检查: @bot.event 消息上的异步定义(消息) 如果isinstance(message.channel、discord.DMChannel)和str(message.author)=“user”: 通道=bot.get\u通道(通道id) 等待频道发送(消息内容) 其他: 通过 bot.process_命令(消息) 对象具有一个可用于检查的属性: @bot.event 消息上的异步定义(消息) 如果i
@bot.event
消息上的异步定义(消息)
如果isinstance(message.channel、discord.DMChannel)和str(message.author)=“user”:
通道=bot.get\u通道(通道id)
等待频道发送(消息内容)
其他:
通过
bot.process_命令(消息)
对象具有一个可用于检查的属性:
@bot.event
消息上的异步定义(消息)
如果isinstance(message.channel、discord.DMChannel)和str(message.author)=“user”:
通道=bot.get\u通道(通道id)
等待频道发送(消息内容)
其他:
通过
bot.process_命令(消息)
这应该适用于一个示例
@bot.event
async def on_message(message)
guild = message.guild
if not guild:
print(" DM: {0.author.name} : {0.content}".format(message))
这应该是一个很好的例子
@bot.event
async def on_message(message)
guild = message.guild
if not guild:
print(" DM: {0.author.name} : {0.content}".format(message))