From 3f9da28d0509105e21904513e6cebc87506f6058 Mon Sep 17 00:00:00 2001 From: flifloo Date: Thu, 9 Apr 2020 14:07:41 +0200 Subject: [PATCH] Raise CommandNotFound on speak setup argument error and fix on_command_error --- extensions/speak.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/extensions/speak.py b/extensions/speak.py index fe0018f..c19acb8 100644 --- a/extensions/speak.py +++ b/extensions/speak.py @@ -139,13 +139,16 @@ class Speak(commands.Cog): if not ctx.author.voice.channel.permissions_for(ctx.author).mute_members: await ctx.message.add_reaction("\u274C") else: - if len(args) != 0 and args[0] == "strict": - self.strict = True - for client in ctx.author.voice.channel.members: - if client != ctx.author and not client.bot and \ - not (self.lastSpeaker and client.id == self.lastSpeaker) and \ - not (self.reaction and client.id == self.lastReaction): - await client.edit(mute=True) + if len(args) != 0: + if args[0] == "strict": + self.strict = True + for client in ctx.author.voice.channel.members: + if client != ctx.author and not client.bot and \ + not (self.lastSpeaker and client.id == self.lastSpeaker) and \ + not (self.reaction and client.id == self.lastReaction): + await client.edit(mute=True) + else: + raise CommandNotFound self.voice_chan = ctx.author.voice.channel.id await ctx.message.add_reaction("\U0001f44d") @@ -206,7 +209,8 @@ class Speak(commands.Cog): @commands.Cog.listener() async def on_command_error(self, ctx: commands.Context, error): - if ctx.invoked_with == extension_name: + if ctx.invoked_with == extension_name or \ + (ctx.command.root_parent is not None and ctx.command.root_parent.name == extension_name): if isinstance(error, CommandNotFound): await ctx.message.add_reaction("\u2753") else: