我正在尝试为 Discord 制作一个机器人,每次我尝试使用以下代码向指定频道发送消息时,它不会给我任何错误,但会打印“None”,这是我期望的该频道不存在。我现在已经在多个公会/服务器和多个文本通道以及运行相同代码的多台计算机上进行了尝试。在下面的代码中,我将channelID替换为int(即channelID),将token替换为我的令牌(字符串)。
import discord
from discord.ext import commands
intents = discord.Intents.all()
client = commands.Bot(command_prefix = 'bday ', intents = intents)
channel = client.get_channel(channelID)
print(channel)
client.run("token")
Run Code Online (Sandbox Code Playgroud)
该机器人确实具有管理员权限,以及两个意图网关