0
@client.command(pass_context=True)
async def coolest(ctx):
      await client.send_message(message.channel, 'Say hello')
      msg = await client.wait_for_message(author=message.author, content='hello')
      await client.send_message(message.channel, 'Hello.')

Its not working. And no errors are appearing. I tried in different way and have done in on_message. But dont know why its not working in client.commands. Help.

Rubayet Python
  • 57
  • 3
  • 5
  • 7
  • Are you sure you run the command with some event loop? `asyncio.run` or anything more low level: https://docs.python.org/3/library/asyncio-task.html#asyncio-example-sleep – newtover Nov 28 '18 at 07:51
  • What else is in your file that could be interfering with this? [Do you have an `on_message` that stops commands from working?](https://stackoverflow.com/questions/49331096/why-does-on-message-stop-commands-from-working). Remove everything else in your file, and see if you can get just this component to fail. You should be left with just `from discord.ext.commands import Bot`, `client = Bot(command_prefix='!')`, this code, and `client.run("token")` – Patrick Haugh Nov 28 '18 at 14:16

1 Answers1

0

You're referring to message throughout this coroutine. Change all these references from message to ctx.message

@client.command(pass_context=True)
async def coolest(ctx):
      await client.send_message(ctx.message.channel, 'Say hello')
      msg = await client.wait_for_message(author=ctx.message.author, content='hello')
      await client.send_message(ctx.message.channel, 'Hello.')

Unless message is defined in an enclosing scope, you should be seeing an error when this happens. You should double check any error-handling code you have to make sure it isn't suppressing unexpected error messages.

Patrick Haugh
  • 59,226
  • 13
  • 88
  • 96