user10773777
user10773777

Reputation:

Bot ignores command, no error message - Discord.py Rewrite

I am pretty new to Python, and I am coding a discord bot using discord.py rewrite, python 3.7. I typed up a command, but the bot seems to completely ignore it, and it doesn't give me any errors.

@client.command(pass_context = True)
async def poll(ctx, polltopic, *pollquestions):
    print("Poll command activated.")
    reactions = [":one:", ":two:", ":three:", ":four:",":five:",":six:", ":seven:", ":eight:", ":nine:", ":ten:"]
    number = 0
    await ctx.send("**POLL:** "+str(polltopic))
    for x in pollquestions:
        await ctx.send(str(reactions[number])+" "+str(x))
        number = number+1

The print function used for debugging shows nothing in the output. As other websites advised me to do, I put:

await client.process_commands(message)

at the end of the on_message function. It is still completely ignoring the command, and not giving me any errors. The problem is probably staring me right in the face, but I don't see it.

Upvotes: 0

Views: 1184

Answers (1)

user10773777
user10773777

Reputation:

I found the error: it had nothing to do with the command syntax itself. I had a return function exiting the on_message function early, before it got to the await client.process_commands(message), so the bot was ignoring the commands.

Upvotes: 1

Related Questions