【发布时间】:2021-07-08 03:30:23
【问题描述】:
我在下面有一个示例代码块,我正在尝试运行它以向特定频道发送消息。当我运行它时,我得到这个错误:AttributeError:'NoneType'对象没有属性'send'。我知道频道 ID 很好。这很简单,但我知道 discord.py,所以我可能会忽略一些东西
import discord
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
intents = discord.Intents(guild_messages=True)
client = discord.Client(intents=intents)
@client.event
async def on_ready():
await client.get_channel(811074101505425418).send("bot is online")
client.run(TOKEN)
【问题讨论】:
-
试试
client.channel.send("bot is online") -
@Goion AttributeError: 'Client' 对象没有属性 'channel' 是我得到的
-
重新检查您的令牌并检查您是否拥有正确的权限。好像不能认证什么的
-
@Goion 我踢了机器人,重新设置了开发者页面上的权限,但我仍然没有运气......对于如此直截了当的事情来说似乎真的很奇怪
-
print(client.user.name)打印什么吗?
标签: python discord.py