-1


I wanna program a simple bot with the discord.py extension, using a tutorial to do so. Against my expectations, it doesn't work the way I want it to. The event listeners are working, but the command doesn't. Do you have any advices for me? Thanks.

import discord
from discord.ext import commands
from discord.ext.commands import Context

client = commands.Bot(command_prefix="&")


@client.event
async def on_ready():
    print('The bot just started, thanks for reviving me.')


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


@client.command(
    name="ping",
    aliases=["p"]
)
async def ping_command(ctx: Context):
    print("test")
    await ctx.channel.send("Pong")


client.run('TOKEN')

1 Answers1

-1

I don't believe that errors are popping up because of the ping command, and adding:

client.process_commands(message)

under the if statement in the on_message event should fix your problem (Also commented by Chuaat).

BFred
  • 7
  • 3