首页 > 解决方案 > (Discord.py) 消息机器人通过 dm,然后发送到频道

问题描述

我正在尝试编写一个代码,您可以向机器人发送帮助、建议或其他任何内容,它会在频道中发送消息。收到消息后,您可以执行 .dm (user) (message),然后机器人将 dm 用户返回。我遇到了一些问题,我对编码很陌生,我认为我的格式已经过时了。如果有人可以提供帮助,那就太棒了。

@vini.event
async def on_message(message):
    channel = vini.get_channel('633053538334932992')
    if message.guild is None and message.author != vini.user:
      await channel.send(message.content)
    await vini.process_commands(message)

@vini.command(pass_context=True)
@commands.is_owner() 
async def dm(ctx):
  memberID = "ID OF RECIPIENT"
  person = await vini.get_user_info(memberID)
  await ctx.send(“WHAT TO SAY", delete_after=2)

错误:

File "main.py", line 133, in on_message
    await channel.send(message.content)
AttributeError: 'NoneType' object has no attribute 'send'

如果有人可以提供帮助,将不胜感激。谢谢!

标签: discord.pydiscord.py-rewrite

解决方案


推荐阅读