Reputation: 15728
When I use the !order
command the Not existing command
message will be sent, how can I avoid that?
My code:
@client.event
async def on_message(message):
channel = message.author
def check(m):
return m.channel == message.channel and m.author != client.user
if message.content.startswith("!order"):
await channel.send("in game name")
in_game_name = await client.wait_for('message', check=check)
await channel.send("in game ID")
in_game_ID = await client.wait_for('message', check=check)
await channel.send("cargo type")
cargo_type = await client.wait_for('message', check=check)
await channel.send("cargo limit")
cargo_limit = await client.wait_for('message', check=check)
await channel.send("storage")
storage = await client.wait_for('message', check=check)
await channel.send("priority")
priority = await client.wait_for('message', check=check)
await client.process_commands(message)
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("Not existing command!")
Upvotes: 1
Views: 176
Reputation: 61052
You can just move the process_commands
into an else
block, so that it only runs if your on_message
does not handle the command
@client.event
async def on_message(message):
channel = message.author
def check(m):
return m.channel == message.channel and m.author != client.user
if message.content.startswith("!order"):
await channel.send("in game name")
in_game_name = await client.wait_for('message', check=check)
await channel.send("in game ID")
in_game_ID = await client.wait_for('message', check=check)
await channel.send("cargo type")
cargo_type = await client.wait_for('message', check=check)
await channel.send("cargo limit")
cargo_limit = await client.wait_for('message', check=check)
await channel.send("storage")
storage = await client.wait_for('message', check=check)
await channel.send("priority")
priority = await client.wait_for('message', check=check)
else:
await client.process_commands(message)
Upvotes: 2