Reputation: 21
I am using the following code to print the latest message on a specific discord channel, but it always brings an empty string.
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')
Any ideas?
Message Content Intent is correctly enabled on the application, and the bot has read message and read message history permissions on the channel.
Upvotes: 2
Views: 422
Reputation: 852
this is the case if your bot dont have the intents setup.
Go to the Discord Developer Portal and to your Bot, then go to Bot and go to the Privilege Gateway Intents and check the Message Content Intent
you have already specified the intents in your code so this should do it
Upvotes: 0