您如何通过 dm 向作者发回消息? - discord.py 重写
How do you send a message back to the author via dm? - discord.py rewrite
这需要上下文,没有它代码就没有意义。
基本上,我们的服务器上有一个名为 69chat 的聊天室。如果上面没有 69,机器人将删除该消息。我想这样做,如果你忘记了 69,它会向你发送你应该发送的消息(只是消息 + 69)。我试过这个:
@bot.event
async def on_message(message):
await bot.process_commands(message)
if message.channel.id == 757140530739150848:
if '69' in message.content:
return
else:
await message.delete()
member = message.author
channel = await member.create_dm()
await channel.send('Add a 69 on your message! You betray the 69 cult! Do this 3 more times and a kick will be coming your way!')
await channel.send("Here's what you should have said:")
await channel.send('{} 69'.format(message))
但是,它刚刚发送了这个:
Add a 69 on your message! You betray the 69 cult! Do this 3 more times and a kick will be coming your way!
Here's what you should have said:
<Message id=758138294000943134 channel=<TextChannel id=757140530739150848 name='⟫-:laughing:・69-chat' position=22 nsfw=False news=False category_id=746479616054788118> type=<MessageType.default: 0> author=<Member id=726314322565005382 name='' discriminator='5540' bot=False nick=' but 69 (69)' guild=<Guild id=736148508171829259 name='jesser101 Youtube Community!' shard_id=None chunked=True member_count=118>> flags=<MessageFlags value=0>> 69
那不是我发的。
如何解决此问题并发送您发送的实际消息?谢谢
message
是一个 Message 对象,因此要获取您发送的消息的内容,请使用 message.content
这需要上下文,没有它代码就没有意义。
基本上,我们的服务器上有一个名为 69chat 的聊天室。如果上面没有 69,机器人将删除该消息。我想这样做,如果你忘记了 69,它会向你发送你应该发送的消息(只是消息 + 69)。我试过这个:
@bot.event
async def on_message(message):
await bot.process_commands(message)
if message.channel.id == 757140530739150848:
if '69' in message.content:
return
else:
await message.delete()
member = message.author
channel = await member.create_dm()
await channel.send('Add a 69 on your message! You betray the 69 cult! Do this 3 more times and a kick will be coming your way!')
await channel.send("Here's what you should have said:")
await channel.send('{} 69'.format(message))
但是,它刚刚发送了这个:
Add a 69 on your message! You betray the 69 cult! Do this 3 more times and a kick will be coming your way!
Here's what you should have said:
<Message id=758138294000943134 channel=<TextChannel id=757140530739150848 name='⟫-:laughing:・69-chat' position=22 nsfw=False news=False category_id=746479616054788118> type=<MessageType.default: 0> author=<Member id=726314322565005382 name='' discriminator='5540' bot=False nick=' but 69 (69)' guild=<Guild id=736148508171829259 name='jesser101 Youtube Community!' shard_id=None chunked=True member_count=118>> flags=<MessageFlags value=0>> 69
那不是我发的。
如何解决此问题并发送您发送的实际消息?谢谢
message
是一个 Message 对象,因此要获取您发送的消息的内容,请使用 message.content