【发布时间】:2023-02-15 21:32:49
【问题描述】:
我正在使用以下代码在特定的不和谐频道上打印最新消息,但它总是带来一个空字符串。
from termcolor import colored
import discord
intents = discord.Intents.default()
intents.members = True
intents.messages = True
client = discord.Client(intents=discord.Intents.all())
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
# Check if the message was sent in the specific channel you want to read from
if message.channel.id == CHANNELID: # replace CHANNEL_ID with the ID of the channel you want to read from
print(colored(message.content, 'green'))
client.run('TOKEN')
有任何想法吗?
消息内容意图在应用程序上正确启用,并且机器人在频道上具有阅读消息和阅读消息历史记录的权限。
【问题讨论】: