[V3] Meaningful responses to bad command arguments #967

Closed
opened 2017-09-07 03:54:40 +02:00 by Tobotimus · 6 comments
Tobotimus commented 2017-09-07 03:54:40 +02:00 (Migrated from github.com)

Right now, when a "Bad Argument" is passed into a command (i.e. when a commands.Converter fails), the bot simply responds with the help message. This doesn't really tell the user why the command failed, and I've seen many users be stumped by this.

I have two ideas for solutions:

  1. Respond saying exactly what conversion failed, e.g. if a commands.MemberConverter fails, it responds with Member "[user]" not found
  2. Make the help message contain better documentation for command arguments.

Disadvantages of each solution:

  1. Relies on a meaningful message being passed into commands.BadArgument when a conversion fails, which brings up potential issues with custom converters (there are no guidelines on how commands.BadArgument should be used).
  2. A more meaningful help message is still fairly ambiguous. The point of error messages is for the user to know exactly what went wrong, not just throwing a bunch of help docs in their face.
Right now, when a "Bad Argument" is passed into a command (i.e. when a `commands.Converter` fails), the bot simply responds with the help message. This doesn't really tell the user why the command failed, and I've seen many users be stumped by this. I have two ideas for solutions: 1. Respond saying exactly what conversion failed, e.g. if a `commands.MemberConverter` fails, it responds with _Member "[user]" not found_ 2. Make the help message contain better documentation for command arguments. Disadvantages of each solution: 1. Relies on a meaningful message being passed into `commands.BadArgument` when a conversion fails, which brings up potential issues with custom converters (there are no guidelines on how `commands.BadArgument` should be used). 2. A more meaningful help message is still fairly ambiguous. The point of error messages is for the user to know exactly what went wrong, not just throwing a bunch of help docs in their face.
Tobotimus commented 2017-09-07 04:33:18 +02:00 (Migrated from github.com)

For reference, these are the messages passed into commands.BadArgument for all situations I found in discord.py.

Converting arguments (commands.converter module):

  • When a commands.MemberConverter fails: Member "{}" not found
  • When a commands.UserConverter fails: User "{}" not found
  • ... and so on for all other converters in the commands.converter module, except for:
  • When a commands.ColourConverter fails: Colour "{}" is invalid
  • When a commands.InviteConverter fails: Invite is invalid or expired

Parsing arguments (commands.view module):

  • Unexpected EOF whilst parsing a quoted argument: Expected closing "
  • Invalid char after closing a quoted argument: Expected space after closing quotation
  • Quote mark being in the middle of an argument: Unexpected quote mark in non-quoted string

Those last 3 error messages seem far too technical to be sending to the user. Which makes solution 1 more difficult 😟

For reference, these are the messages passed into `commands.BadArgument` for all situations I found in discord.py. Converting arguments (`commands.converter` module): - When a `commands.MemberConverter` fails: _Member "{}" not found_ - When a `commands.UserConverter` fails: _User "{}" not found_ - ... and so on for all other converters in the `commands.converter` module, except for: - When a `commands.ColourConverter` fails: _Colour "{}" is invalid_ - When a `commands.InviteConverter` fails: _Invite is invalid or expired_ Parsing arguments (`commands.view` module): - Unexpected EOF whilst parsing a quoted argument: _Expected closing "_ - Invalid char after closing a quoted argument: _Expected space after closing quotation_ - Quote mark being in the middle of an argument: _Unexpected quote mark in non-quoted string_ Those last 3 error messages seem far too technical to be sending to the user. Which makes solution 1 more difficult :worried:
Kowlin commented 2017-09-08 16:01:10 +02:00 (Migrated from github.com)

Absolutely doable. However I think its the best if this is done on a per command basis, due the fact that commands require different arguments.

Absolutely doable. However I think its the best if this is done on a per command basis, due the fact that commands require different arguments.
Tobotimus commented 2017-09-10 14:41:05 +02:00 (Migrated from github.com)

discord.py#773 could help us out here, pending a merge

[discord.py#773](https://github.com/Rapptz/discord.py/pull/773) could help us out here, pending a merge
mikeshardmind commented 2018-06-02 08:48:39 +02:00 (Migrated from github.com)

Without any additional info, and that PR still open months later in discord.py, is this worth putting in redbot.core.commands @Tobotimus ?

Without any additional info, and that PR still open months later in discord.py, is this worth putting in `redbot.core.commands` @Tobotimus ?
Tobotimus commented 2018-06-03 02:00:20 +02:00 (Migrated from github.com)

@mikeshardmind Good point! I hadn't actually thought of that. We could probably do it by just overriding commands.Command.transform(), by calling the super and catching commands.BadArgument. Edit: after further inspection it looks a bit trickier than that, but I'm sure it's doable. Edit 2: commands.Command.do_conversion is what I was looking for!

@mikeshardmind Good point! I hadn't actually thought of that. ~~We could probably do it by just overriding `commands.Command.transform()`, by calling the super and catching `commands.BadArgument`.~~ Edit: after further inspection it looks a bit trickier than that, but I'm sure it's doable. Edit 2: `commands.Command.do_conversion` is what I was looking for!
tekulvw commented 2018-06-09 03:20:58 +02:00 (Migrated from github.com)

Fixed with #1817

Fixed with #1817
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#967
No description provided.