SomeGuy
SomeGuy

Reputation: 89

discord.py command message is taking in as non command message

I have this issue where I want to take input as a command so the user types !ping and my prefix is !, but for some reason it does not direct towards:

@client.command()
async def ping(ctx):
    print("Someone asked for their latency")

for some reason it directs it to:

@client.event
async def on_message(message):
    print("Someone send a message")

I want when a user types !ping it directs it to ping(ctx) and not on_message(message) like it is doing right not. This is my full code:

import discord
from discord.ext import commands

intents = discord.Intents.all()
client = commands.Bot(command_prefix="!", intents=intents)


@client.event
async def on_ready():
    print("I am ready")


@client.event
async def on_member_join(member):
    join_embed = discord.Embed(title=f'{member.name} Joined :)',
                               description=f"Hey {member.name} remember that addison is weird", colour=16366985)
    join_embed.set_image(url="https://www.desicomments.com/wp-content/uploads/2017/07/Hi.gif")
    await member.guild.system_channel.send(content=None, embed=join_embed)
    print("joined")


@client.event
async def on_member_remove(member):
    left_embed = discord.Embed(title=f'{member.name} Left :(',
                               description=f"Bye Bye {member.name}", colour=16726802)
    left_embed.set_image(url="http://www.reactiongifs.com/wp-content/uploads/2012/12/byebye.gif")
    await member.guild.system_channel.send(content=None, embed=left_embed)
    print("left")

@client.event
async def on_message(message):
    print("Someone sent a message")


@client.command()
async def ping(ctx):
    print("Someone asked for their latency")

client.run('hajslkdhasjlkdhjwheq')

Upvotes: 0

Views: 21

Answers (1)

LoahL
LoahL

Reputation: 2613

You can simply add await client.process_commands(message) as the last line in on_message() to fix this problem

Upvotes: 1

Related Questions