首页 > 解决方案 > 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)

标签: pythondiscord.pynonetype

解决方案


推荐阅读