I have a function in my Discord bot that acts as a magic 8 ball where you ask it a question and gives a random reply. An exception occurs when the function is called but no question is asked, and I would like to get an error message of some kind print to the channel it was called in notifying the user that this error as occurred. Here's what I attempted:
@client.command(aliases=['8ball', 'eightball'])
async def _8ball(ctx, *,question):
responses = ['yes', 'no', 'maybe so']
response = random.choice(responses)
try:
await ctx.send(f'Question: {question}\n\
Answer: {response}')
except MissingRequiredArgument:
await ctx.send("Please ask a question")
pass
But nothing prints out except in the terminal. Any suggestions?