Quantcast
Viewing all articles
Browse latest Browse all 14069

Discord bot can't send messages from the server but sends messages from dm

I have made one discord bot in the past it work perfectly but when I tried makeing another just like that it don't work it doesn't respond to my messages in the server but it respond in the private dms I tried to debug it by print statements but it don't receive the message from the server, I have checked the permissions and remove and add the bot again and also made another one and new servers but both of them don't message in servers

It's the code I written.

import discordimport osintents = discord.Intents.default()intents.messages = True  # Enable message eventskey = os.environ['Key']client = discord.Client(intents=intents)@client.eventasync def on_ready():    print('Connected!')@client.eventasync def on_message(message):    if message.author == client.user:        return    print(f"Received message: {message.content}")  # Debug print statement    if message.content.startswith('hello'):        print('Responding to hello message')  # Debug print statement        await message.channel.send('Hello!')client.run(key)

Thank-you

The bot works fine when I chat in the dms but it can't read the messages on a server


Viewing all articles
Browse latest Browse all 14069

Trending Articles