您如何通过dm发回消息给作者? -discord.py重写

时间:2020-09-23 01:41:52

标签: python discord.py 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

那不是我发的。

如何解决此问题并发送实际发送的消息?谢谢。

1 个答案:

答案 0 :(得分:1)

messageMessage对象,因此使用message.content

来获取发送的消息的内容