@commands.command(aliases=['s'])
async def subscribe(self, ctx, subscribtion):
"""foo bar"""
Ignoring exception in command subscribe:
Traceback (most recent call last):
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a1+gb5ddc99-py3.7.egg\discord\ext\commands\bot.py", line 898, in invoke
await ctx.command.invoke(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a1+gb5ddc99-py3.7.egg\discord\ext\commands\core.py", line 543, in invoke
await self.prepare(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a1+gb5ddc99-py3.7.egg\discord\ext\commands\core.py", line 508, in prepare
await self._parse_arguments(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a1+gb5ddc99-py3.7.egg\discord\ext\commands\core.py", line 426, in _parse_arguments
transformed = await self.transform(ctx, param)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a1+gb5ddc99-py3.7.egg\discord\ext\commands\core.py", line 323, in transform
argument = quoted_word(view)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a1+gb5ddc99-py3.7.egg\discord\ext\commands\view.py", line 189, in quoted_word
raise BadArgument('Expected space after closing quotation')
discord.ext.commands.errors.BadArgument: Expected space after closing quotation
When executing
<prefix> """ +
where "
It's unclear what your issue is.
When executing
<prefix> """ +
where "" is your bots prefix
Is the message you're sending "" """ + where your prefix is ""?
How is this related to your subscribe command?
It's unclear what your issue is.
I thought it was very clear
It doesn't matter what the command is doing. The library has a bug.
Lets say the
!subscribe """ +
Breaks any command. So far we have tested it in multiple bots which resulted in the same error message which can be found in the top post
Your first post made it look like the prefix being "" broke it. That's why it was unclear.
Your first post made it look like the prefix being "" broke it. That's why it was unclear.
Hope its more clear now, Is anyone up to test this too?
Tested it and can't reproduce.
Tested it and can't reproduce.
Interesting, same code runs fine on windows machine,
However, I do know a hand full of people who actually can reproduce this issue. 馃
What is your version of the rewrite branch and what python you run from? @LewdNeko
Latest rw (cba to check but updated it yesterday), Py 3.6, Ubuntu 16.04
Are you sure your command is actually inside a class and self isnt being passed ctx and ctx passed """? That seems more likely.
Latest rw (cba to check but updated it yesterday), Py 3.6, Ubuntu 16.04
Inserting, I'm running discord.py-1.0.0a1 on Ubuntu 18.04
Are you sure your command is actually inside a class and self isnt being passed ctx and ctx passed """? That seems more likely.
100%, positive command is being called in a cog class. CTX is also being passed. Also the function itself works perfectly. It only seems to happen on on any other command when using the command <prefix><command> """ +. It doesn't matter what function(command) call it is.
I do make use of on_message which processes strings to commands, however even breakpoints wont trigger in this on_message when calling <prefix><command> """ +.
I strongly believe its not my code since the traceback points to discord.py rewrite branch.
One thing to note is that i'm probably using a outdated version of the lib which may cause this problem.
I can validate this later today. The last time I downloaded the package was around July
I'm also unable to reproduce this with a command that doesn't expect any input arguments.
The latest version of the rewrite branch is currently v1.0.0a1650+g1222bce.
The version of discord.py used in the traceback is at least 4 months out of date. Furthermore the commit b5ddc99 does not exist in the repository. Whatever you have installed, it is not the latest rewrite branch.
Updated to the latest commit, to my supprise same issue.
Ignoring exception in command subscribe:
Traceback (most recent call last):
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\bot.py", line 898, in invoke
await ctx.command.invoke(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 604, in invoke
await self.prepare(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 569, in prepare
await self._parse_arguments(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 487, in _parse_arguments
transformed = await self.transform(ctx, param)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 350, in transform
argument = quoted_word(view)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\view.py", line 187, in quoted_word
raise BadArgument('Expected space after closing quotation')
discord.ext.commands.errors.BadArgument: Expected space after closing quotation
It even seems to happen with the default help command
Ignoring exception in command help:
Traceback (most recent call last):
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\bot.py", line 898, in invoke
await ctx.command.invoke(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 604, in invoke
await self.prepare(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 569, in prepare
await self._parse_arguments(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 501, in _parse_arguments
transformed = await self.transform(ctx, param)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 350, in transform
argument = quoted_word(view)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\view.py", line 187, in quoted_word
raise BadArgument('Expected space after closing quotation')
discord.ext.commands.errors.BadArgument: Expected space after closing quotation
My on_message
async def on_message(self, message):
"""
The event triggered when an message is coming in which has bot content
Message : message
"""
# returns if message in subscribe channel not starts with prefix
if message.channel.id == 540646397385637888: return # ignore betas channel
subscribe = discord.utils.get(self.get_all_channels(), id=self.channelSubscribe)
if message.channel.id == subscribe.id:
if not re.match(self.re_subscribe_check, message.content) and not message.author.bot:
return await message.delete()
# return is the message is from a bot or the message starts not with the prefix
if message.author.bot or not message.content.startswith(self.prefix): return
# Process the message as a command
await self.process_commands(message)
Very weird this is happening
The default help command accepts input, so that is expected behavior.
If your subscribe command also expects input arguments, unlike the one in your original issue description, then that is expected behavior as well.
It is expected behavior
I see the subscribe foo bar func in example above misses the args, my mistake
But why it raises a BadArgument on """ +. It should be handled as a string.
It is expected behavior that an input argument of """ will raise BadArgument because quotation marks are used to enter input with spaces, and like the error says, a space is expected after the closing quotation mark to signify the end of the argument.
See https://discordpy.readthedocs.io/en/rewrite/ext/commands/commands.html#parameters
I'm not sure how else you expect that input to be parsed.
To use a quotation mark inside a string, you can simply escape it:
https://github.com/Rapptz/discord.py/blob/1222bce271cf736b4db8c1eecb2823edd22f85dc/discord/ext/commands/view.py#L158
For future questions like this, you should join either the official discord.py server or the Discord API server for help, as the README recommends.
It is expected behavior that an input argument of
"""will raiseBadArgumentbecause quotation marks are used to enter input with spaces, and like the error says, a space is expected after the closing quotation mark to signify the end of the argument.
In this case it should not matter since the input of a user gets unpacked. (basically what you showed in the doc link), Its very weird behavior that this exception also get raised from the default help function. I would've sworn that the default help function accepts *args.
To use a quotation mark inside a string, you can simply escape it:
to embed a quote inside the string you must escape it: "a "world""
Besides I'm not looking to escape quotes, I can't edit a users message before it enters the startpoint of the api. It won't even enter my on_message function which is odd.
For future questions like
This is not a question but something wrong in the api. To verify this i have made a snippet of my actual code which you could inspect. It's easy to draw quick conclusions.
run.py
from discord.ext import commands
import discord
class SteamNews(commands.Bot, Config):
def __init__(self):
Config.__init__(self)
commands.Bot.__init__(self, command_prefix=self.prefix)
async def on_message(self, message):
"""
The event triggered when an message is coming in which has bot content
Message : message
"""
# returns if message in subscribe channel not starts with prefix
if message.channel.id == 540646397385637888: return # ignore betas channel
subscribe = discord.utils.get(self.get_all_channels(), id=self.channelSubscribe)
if message.channel.id == subscribe.id:
if not re.match(self.re_subscribe_check, message.content) and not message.author.bot:
return await message.delete()
# return is the message is from a bot or the message starts not with the prefix
if message.author.bot or not message.content.startswith(self.prefix): return
# Process the message as a command
await self.process_commands(message)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
steamnews = SteamNews()
loop.run_until_complete(steamnews.run())
cog.py
class Subscribe:
def __init__(self, bot):
self.bot = bot
@commands.command(aliases=['s'])
@commands.cooldown(rate=1, per=15, type=commands.BucketType.user)
async def subscribe(self, ctx, *, game=None):
"""Subscirbe to your favorite game"""
# Do stuff
def setup(bot):
bot.add_cog(Subscribe(bot))
Once more the error >
Ignoring exception in command help:
Traceback (most recent call last):
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\bot.py", line 898, in invoke
await ctx.command.invoke(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 604, in invoke
await self.prepare(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 569, in prepare
await self._parse_arguments(ctx)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 501, in _parse_arguments
transformed = await self.transform(ctx, param)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\core.py", line 350, in transform
argument = quoted_word(view)
File "d:\python_projecten\SteamNews\DiscordBot\SteamNews\venv\lib\site-packages\discord.py-1.0.0a11+gbe28250-py3.7.egg\discord\ext\commands\view.py", line 187, in quoted_word
raise BadArgument('Expected space after closing quotation')
discord.ext.commands.errors.BadArgument: Expected space after closing quotation
Just a reminder that I have no interests in escaping characters in any embed whats however.
The user input should correctly be handled as a String type which the backend magic does,
""" + should be str('""" +'). Oh and one more thing If this was normal behavior other people in this thread would experience the same error on any func call with the args """ + which they don't. So no, its not normal behavior.
In this case it should not matter since the input of a user gets unpacked. (basically what you showed in the doc link)
The second quotation mark is not escaped, so when the input is parsed, the argument is taken to be an empty string with the first two quotation marks. The third quotation mark raises the BadArgument error as the parser does not expect anything after the second quotation mark besides a space, as that should be the end of the input for that argument.
Its very weird behavior that this exception also get raised from the default help function. I would've sworn that the default help function accepts *args.
The default help command accepts a variable number of parameters.
As the documentation notes, this has the same multi-word argument parsing for quotation marks as positional parameters.
Besides I'm not looking to escape quotes, I can't edit a users message before it enters the startpoint of the api.
This has nothing to do with changing a user's message.
The expected behavior for that input is to raise BadArgument because the parser doesn't know how to interpret it. This is caused by an error in user input, the same way BadArgument is raised when a user enters something invalid for a channel, user, role, etc. input conversion.
It won't even enter my on_message function which is odd.
This is not true. The error is raised when the command is invoked, which happens when you process the command in on_message.
This is not a question but something wrong in the api.
I already told you this is expected behavior, and I thought you agreed, since you said:
It is expected behavior
Hence why I referred you to the Discord servers, as I thought you were continuing with questions.
Regardless, this is not an issue with the library.
Just a reminder that I have no interests in escaping characters in any embed whats however.
Escaping quotation marks in input for multi-word arguments has nothing to do with embeds.
The user input should correctly be handled as a String type which the backend magic does,
""" +should bestr('""" +').
I already explained why this doesn't make sense and isn't the case for positional and variable parameters.
As for keyword-only arguments, like in this subscribe command, that is the expected behavior and is what happens. I'm unable to reproduce the issue with a command with only a keyword-only argument parameter. game is successfully set to '""" +'.
Also, as previously noted, the latest version of the rewrite branch is currently v1.0.0a1650+g1222bce, not v1.0.0a11+gbe28250. The commit be28250 also does not exist in the repository.
Oh and one more thing If this was normal behavior other people in this thread would experience the same error on any func call with the args
""" +which they don't.
I'm not sure what you mean. @LewdNeko likely didn't encounter a BadArgument error like I didn't, simply because your initial issue description was for a command with no input arguments. Like I've explained, """ is only an invalid input for positional and variable parameters, so those are the only cases for which it'll raise BadArgument. As far as I'm aware, no one else who has commented on this issue has said this is not the case. Otherwise, I'm not sure why """ + would be common input at all or what it would even mean.
Please @Annihilator708, this is an issue with escaping quotation marks, not the parsing of command arguments. I agree fully with Harmon.
@laggycomputer Yes
@Harmon758 , Thank you for your response/time.
I understand, however. It feels just wrong.
It's like you notice a sql injection in your database but can't do anything about it.
Also, as previously noted, the latest version of the rewrite branch is currently v1.0.0a1650+g1222bce, not v1.0.0a11+gbe28250. The commit be28250 also does not exist in the repository.
The last version i got was just from this link tbh
https://github.com/Rapptz/discord.py/tree/rewrite
This is not true. The error is raised when the command is invoked, which happens when you process the command in on_message.
You are 100% right, Seems like it happens on process_commands, however I'm unable to catch the error
from discord.ext import commands
try:
await self.process_commands(message)
except (commands.errors.BadArgument):
print('RIP')
Hence why I referred you to the Discord servers,
Please don't, This way if any other person walks against the same issue it is actually google-able.
Github is in a way made for that.
Do i really need to call on_command_error before I can catch this error?
async def on_command_error(self, ctx, error):
if isinstance(error, commands.BadArgument):
return print('Rip')
Seems like this resolves the issue ^
~ Thank you for your time
It's like you notice a sql injection in your database but can't do anything about it.
An SQL injection is a type of attack and usually nefarious in nature. This is just invalid user input which the library raises an error for and you can handle.
The last version i got was just from this link tbh
As you can see, the latest commit is 1222bce, not be28250, and there are 1650 total commits, not 11. You are not installing from the rewrite branch of this repository.
You are 100% right, Seems like it happens on process_commands, however I'm unable to catch the error
from discord.ext import commands try: await self.process_commands(message) except (commands.errors.BadArgument): print('RIP')
This is not the right way to handle errors in commands.
Do i really need to call
on_command_errorbefore I can catch this error?
No, on_command_error is called for errors in commands automatically, like any other event.
See the documentation for error handling in commands.
Please don't, This way if any other person walks against the same issue it is actually google-able.
Github is in a way made for that.
This is not an issue with discord.py. GitHub issues for this repository should be used to report issues with this library. They are not a medium for requesting help with using the library. Discord messages in the aforementioned servers are searchable, and there are other googleable forums for asking for help (e.g. Stack Overflow). Regardless, this issue should be closed now, since your issue is resolved.
It's just not an issue, just badly implemented in my opinion