discord.pydiscord.net

Hey, I just created a discord bot using PyCharm and its all going good, but when i try to send !hi or hi it doesnt send Hello back. can anyone help me


import discord

intents = discord.Intents(messages=True)
client = discord.Client(command_prefix='!', intents=intents)
import random
import time
import asyncio

TOKEN = "<My token>"

intents = discord.Intents(messages=True)


@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client)) 


@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith("hi"):   #whenever i type this
        await message.channel.send("Hello") #i dont get this 


@client.event
async def on_ready():
    print("Running!")


client.run(TOKEN) #Token

thanks for the help,i just need the program to say hello when i say hi, I am kinda new to making bots soo yeah. I copied this from a youtube vid, but the intents i did by myself. I am using 3.8 version of Python, it runs without errors


Solution

  • This may be because you did not update your intents or in general something wrong with the intents,

    Intents on the discord developer portal are in the Bot Section, Intents

    If these are enabled then try printing message.content to see if it returns blank or what the user says.