Change intents to discord.Intents.all()… I also suggest you don’t use message.content.startswith to check if something is a command, and instead use @commands.Command()
I made a template for this a while back that should still be working if you want to try it: https://replit.com/@InvisibleOne/Working-Discordpy-Template
Also if you want to use slash commands you can do so like this, but they are a bit more complicated to use:
import discord
import asyncio
from discord import app_commands
import os
intents = discord.Intents.all()
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
ID = 10237408734809 # that's just some random numbers but it should look something like that
@tree.command(name="hello", description="say hello", guild=discord.Object(id=ID))
async def hello(interaction):
await interaction.response.send_message("Hello!")
@client.event
async def on_ready():
await tree.sync(guild=discord.Object(id=ID))
print("Ready!")
def main():
client.run(os.environ["TOKEN"])
asyncio.run(main())
Oh and again… I’m an idiot, the real reason it’s probably not working is because you recreated the on_message event a bunch of times, you only do it once and then just use if to check what the message is…
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("!hi"):
await message.channel.send("hello")
elif message.content.startswith("!ping"):
await message.channel.send("pong")
That’s great news @soggygamer22 , if @InvisibleOne has helped you solve your issue please mark one of their posts as the solution as this can help others in the community in the future.