0

**

** UPDATE: SOLVED

Hi, So im making a bot with the code below in python and i cant figure out why the commands arent working in discord. the only one that works is the one that i stole from the docs website. i removed some other commands that dont work but even just a reply command didnt work. my print to terminal script doesnt work either. my code is below lmk about a solution:

(i removed the libraries and stuff for simplicity in this post)

#sets prefix and loads intents
client = commands.Bot(command_prefix = "!", intents = discord.Intents.default())


#on ready message log in terminal
@client.event
async def on_ready():
    print('bot online')    


#hello command which btw is the only one that works rn
@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('!hello'):
        await message.channel.send('Hello!')

#ping ms command
@client.command()
async def ping(ctx):
    await ctx.channel.send(f'Pong! {round(client.latency * 1000)}ms')



#set status
@client.event
async def on_ready():
    await client.change_presence(activity = discord.Game('being useless'))



client.run(token)

there hasnt been anything to try because no one in the discord server could reproduce or figure out my issue.

BradTFT
  • 1
  • 4
  • See [this](https://stackoverflow.com/questions/71671180/unable-to-use-any-other-commands-after-making-event-to-delete-messages-within-a/71671987#71671987). Also you can combine the `on_ready()` events, you don't need two of them. The first one won't even take effect. – 3nws Apr 04 '22 at 15:46
  • If it's solved, please post or accept an answer. – TheFungusAmongUs Apr 04 '22 at 18:36

2 Answers2

0

await bot.process_commands(message.content)

Your now working code:

#sets prefix and loads intents
client = commands.Bot(command_prefix = "!", intents = discord.Intents.default())


#on ready message log in terminal
@client.event
async def on_ready():
    print('bot online')    


#hello command which btw is the only one that works rn
@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('!hello'):
        await message.channel.send('Hello!')
    else:
       await bot.process_commands(message.content)
    

#ping ms command
@client.command()
async def ping(ctx):
    await ctx.channel.send(f'Pong! {round(client.latency * 1000)}ms')

#set status
@client.event
async def on_ready():
    await client.change_presence(activity = discord.Game('being useless'))

client.run(token)
L8R
  • 401
  • 5
  • 21
0
await bot.process_commands(message)

Code example:

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

if message.content.startswith('!hello'):
    await message.channel.send('Hello!')
else:
    await client.process_commands(message)