discord.py - (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'
如果有人可以提供帮助,将不胜感激。谢谢!
解决方案
推荐阅读
- php - Laravel 通过模型关系
- .net - 虚拟模板和技能模板有什么区别
- javascript - React Native (Android) 没有感知到我的
绝对位于 a 上方的组件 - javascript - Chrome 扩展的 Javascript 帮助
- c# - 如何在 C# 中将 JSON 转换为自定义对象类并访问属性
- python - 在 MoviePy 中有效地逐帧更改文本属性?
- python - 从网页的表格中抓取一定范围
- r - R 中的自举:预测
- java - 在我的存储库中使用 @Query 的 MockMVC 或重构我的控制器以不使用它?
- java - Java 编程语言中的扩展是什么