1
0
Fork 0

Raise CommandNotFound on speak setup argument error and fix on_command_error

This commit is contained in:
Ethanell 2020-04-09 14:07:41 +02:00
parent 9e4cd64950
commit 3f9da28d05

View file

@ -139,13 +139,16 @@ class Speak(commands.Cog):
if not ctx.author.voice.channel.permissions_for(ctx.author).mute_members: if not ctx.author.voice.channel.permissions_for(ctx.author).mute_members:
await ctx.message.add_reaction("\u274C") await ctx.message.add_reaction("\u274C")
else: else:
if len(args) != 0 and args[0] == "strict": if len(args) != 0:
self.strict = True if args[0] == "strict":
for client in ctx.author.voice.channel.members: self.strict = True
if client != ctx.author and not client.bot and \ for client in ctx.author.voice.channel.members:
not (self.lastSpeaker and client.id == self.lastSpeaker) and \ if client != ctx.author and not client.bot and \
not (self.reaction and client.id == self.lastReaction): not (self.lastSpeaker and client.id == self.lastSpeaker) and \
await client.edit(mute=True) not (self.reaction and client.id == self.lastReaction):
await client.edit(mute=True)
else:
raise CommandNotFound
self.voice_chan = ctx.author.voice.channel.id self.voice_chan = ctx.author.voice.channel.id
await ctx.message.add_reaction("\U0001f44d") await ctx.message.add_reaction("\U0001f44d")
@ -206,7 +209,8 @@ class Speak(commands.Cog):
@commands.Cog.listener() @commands.Cog.listener()
async def on_command_error(self, ctx: commands.Context, error): 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): if isinstance(error, CommandNotFound):
await ctx.message.add_reaction("\u2753") await ctx.message.add_reaction("\u2753")
else: else: