python - discord.py - 无法将消息副本从一台服务器发送到另一台特定服务器
问题描述
每当我尝试运行我的代码时,我都会收到以下错误。我已经多次重新检查了我的频道 ID,并且还从 discord 开发人员面板中启用了 Privileged Gateway Intents。Bot 具有管理员权限,因此这不应该成为问题。我正在使用 replit 作为我的 IDE。请帮忙
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 28, in on_message
await general.send (**message.content + ' . ' +message.author.name)
AttributeError: 'NoneType' object has no attribute 'send'
机器人的代码如下:
import os
import discord
intents = discord.Intents.default()
intents.members= True
client= discord.Client( intents=intents)
@client.event
async def on_ready():
print('i am ready ')
my_secret = os.environ['TOKEN']
@client.event
async def on_message(message):
if message.author== client.user:
return
if message.content.startswith('$work'):
general = client.get_channel(849317968193912842)
await general.send (**message.content + ' . ' +message.author.name)
if message.content.startswith('tesla'):
await message.channel.send('elon musk' )
client.run(my_secret)
解决方案
推荐阅读
- c# - 同一作业上有两个 cron 计划,但只有一个正在触发
- sql - 如何清除/删除 SQL Server 中的隐藏字符或特殊字符列?
- html - 无法打开在链接 href="tel:#000#" 上包含 # 字符的电话语法
- javascript - worker-loader 内联做什么?
- python - Python散点图:相同的颜色不接触
- matlab - 如何检查对象是否是 Handle 的子类
- react-native - 从 Stack Navigator 切换选项卡屏幕
- powershell - 使用来自多个组的用户从 AD 中提取数据并在 Export-CSV 中显示这些组
- python-3.x - 将字典与元组作为列表的键进行比较
- r - 奇怪的 x 轴缩放 - ggplot2