I am making a basic discord bot (python) and it should print out into the terminal who messaged what and in what channel. The only issue is when it prints out the message part in the terminal it is blank as if nothing was there. My code is intended to respond but it isn't "seeing" what I message in discord. There is no error message. Image of the terminal
import discord
import random
import os
client = discord.Client(intents=discord.Intents.default())
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f'{username}: {user_message} ({channel}))')
Then I would make it respond to what I messaged but it doesn't SEE the message. If it's a really stupid mistake sorry I'm a starter
CodePudding user response:
you should activate the message content intent in discord.com/developers/applications then replace :
discord.Client(intents=discord.Intents.default())
With discord.Client(intents=discord.Intents.all())