mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Add meaningful error messages for bad arguments in [p]bank set (#4801)
* bot will give meaning full message for bad argument * reformated python code and updated warning message! * warning message updated * warning message updated * warning message updated(1) * warning message updated(2) * warning message updated(3) * Address the review Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
ef803072fa
commit
a4db7a1028
@ -101,19 +101,30 @@ def guild_only_check():
|
||||
class SetParser:
|
||||
def __init__(self, argument):
|
||||
allowed = ("+", "-")
|
||||
try:
|
||||
self.sum = int(argument)
|
||||
except ValueError:
|
||||
raise commands.BadArgument(
|
||||
_(
|
||||
"Invalid value, the argument must be an integer,"
|
||||
" optionally preceded with a `+` or `-` sign."
|
||||
)
|
||||
)
|
||||
if argument and argument[0] in allowed:
|
||||
if self.sum < 0:
|
||||
self.operation = "withdraw"
|
||||
elif self.sum > 0:
|
||||
self.operation = "deposit"
|
||||
else:
|
||||
raise RuntimeError
|
||||
raise commands.BadArgument(
|
||||
_(
|
||||
"Invalid value, the amount of currency to increase or decrease"
|
||||
" must be an integer different from zero."
|
||||
)
|
||||
)
|
||||
self.sum = abs(self.sum)
|
||||
elif argument.isdigit():
|
||||
self.operation = "set"
|
||||
else:
|
||||
raise RuntimeError
|
||||
self.operation = "set"
|
||||
|
||||
|
||||
@cog_i18n(_)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user