diff --git a/redbot/cogs/economy/economy.py b/redbot/cogs/economy/economy.py index 6d56f75e4..39db1c9d2 100644 --- a/redbot/cogs/economy/economy.py +++ b/redbot/cogs/economy/economy.py @@ -101,19 +101,30 @@ def guild_only_check(): class SetParser: def __init__(self, argument): allowed = ("+", "-") - self.sum = int(argument) + 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(_)