Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.73k stars 2.3k forks source link

Ignored alias error from smart quotes #3055

Open Flame442 opened 4 years ago

Flame442 commented 4 years ago

Command bugs

Command name

Any aliased command

What cog is this command from?

Alias

What were you expecting to happen?

The alias to function.

What actually happened?

Ignored exception in console and no response from the bot.

How can we reproduce this issue?

[p]alias add aaa userinfo [p]aaa “

Other Info

This bug was found by SyntheticBee

Error:

Ignoring exception in on_message
Traceback (most recent call last):
  File "\venv\lib\site-packages\discord\client.py", line 270, in _run_event
    await coro(*args, **kwargs)
  File "\venv\lib\site-packages\redbot\cogs\alias\alias.py", line 446, in on_message
    await self.maybe_call_alias(message, aliases=aliases)
  File "\venv\lib\site-packages\redbot\cogs\alias\alias.py", line 210, in maybe_call_alias
    await self.call_alias(message, prefix, alias)
  File "\venv\lib\site-packages\redbot\cogs\alias\alias.py", line 215, in call_alias
    args = self.get_extra_args_from_alias(message, prefix, alias)
  File "\venv\lib\site-packages\redbot\cogs\alias\alias.py", line 185, in get_extra_args_from_alias
    word = view.get_quoted_word()
  File "\venv\lib\site-packages\discord\ext\commands\view.py", line 148, in get_quoted_word
    raise ExpectedClosingQuoteError(close_quote)
discord.ext.commands.errors.ExpectedClosingQuoteError: Expected closing ”.
Twentysix26 commented 4 years ago

I can confirm that this happens even with "normal" quotes
__init__.py

from .poc import Poc

def setup(bot):
    bot.add_cog(Poc())

poc.py

from redbot.core import commands

class Poc(commands.Cog):
    @commands.group()
    async def base(self, ctx: commands.Context):
        ...

    @base.group()
    async def subgroup(self, ctx: commands.Context):
        ...

    @subgroup.command()
    async def cmd(self, ctx: commands.Context, *, my_str: str):
        await ctx.tick()

It can throw two different exceptions based on what is passed:

  1. [p]alias add b base 2a. [p]b subgroup cmd "
    Ignoring exception in on_message_without_command
    Traceback (most recent call last):
    File "***/lib/python3.8/site-packages/discord/client.py", line 312, in _run_event
    await coro(*args, **kwargs)
    File "***/lib/python3.8/site-packages/redbot/cogs/alias/alias.py", line 436, in on_message_without_command
    await self.call_alias(message, prefix, alias)
    File "***/lib/python3.8/site-packages/redbot/cogs/alias/alias.py", line 178, in call_alias
    args = alias.get_extra_args_from_alias(message, prefix)
    File "***/lib/python3.8/site-packages/redbot/cogs/alias/alias_entry.py", line 62, in get_extra_args_from_alias
    word = view.get_quoted_word()
    File "***/lib/python3.8/site-packages/discord/ext/commands/view.py", line 148, in get_quoted_word
    raise ExpectedClosingQuoteError(close_quote)
    discord.ext.commands.errors.ExpectedClosingQuoteError: Expected closing ".

    2b. [p]b subgroup cmd """

    Ignoring exception in on_message_without_command
    Traceback (most recent call last):
    File "***/lib/python3.8/site-packages/discord/client.py", line 312, in _run_event
    await coro(*args, **kwargs)
    File "***/lib/python3.8/site-packages/redbot/cogs/alias/alias.py", line 436, in on_message_without_command
    await self.call_alias(message, prefix, alias)
    File "***/lib/python3.8/site-packages/redbot/cogs/alias/alias.py", line 178, in call_alias
    args = alias.get_extra_args_from_alias(message, prefix)
    File "***/lib/python3.8/site-packages/redbot/cogs/alias/alias_entry.py", line 62, in get_extra_args_from_alias
    word = view.get_quoted_word()
    File "***/lib/python3.8/site-packages/discord/ext/commands/view.py", line 181, in get_quoted_word
    raise InvalidEndOfQuotedStringError(next_char)
    discord.ext.commands.errors.InvalidEndOfQuotedStringError: Expected space after closing quotation but received '"'