mirror of https://github.com/stijndcl/didier
Catch discord error, make "all" match uppercase
parent
dc7e982491
commit
f6d06eb489
|
@ -70,7 +70,7 @@ class Bitcoin(commands.Cog):
|
||||||
if not resp[0]:
|
if not resp[0]:
|
||||||
return await ctx.send(resp[1])
|
return await ctx.send(resp[1])
|
||||||
|
|
||||||
if amount == "all":
|
if str(amount).lower() == "all":
|
||||||
amount = resp[1]
|
amount = resp[1]
|
||||||
|
|
||||||
# Calculate the amount of Bitcoins the user can buy with [amount] of Didier Dinks
|
# Calculate the amount of Bitcoins the user can buy with [amount] of Didier Dinks
|
||||||
|
@ -93,7 +93,7 @@ class Bitcoin(commands.Cog):
|
||||||
:param ctx: Discord Context
|
:param ctx: Discord Context
|
||||||
:param amount: the amount of Bitcoins the user wants to sell
|
:param amount: the amount of Bitcoins the user wants to sell
|
||||||
"""
|
"""
|
||||||
if amount == "all":
|
if str(amount).lower() == "all":
|
||||||
amount = float(currency.getOrAddUser(ctx.author.id)[8])
|
amount = float(currency.getOrAddUser(ctx.author.id)[8])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -288,7 +288,7 @@ class Dinks(commands.Cog):
|
||||||
await ctx.send(checks.isValidAmount(ctx, amount[0])[1])
|
await ctx.send(checks.isValidAmount(ctx, amount[0])[1])
|
||||||
else:
|
else:
|
||||||
user = currency.getOrAddUser(ctx.author.id)
|
user = currency.getOrAddUser(ctx.author.id)
|
||||||
if amount[0] == "all":
|
if str(amount[0]).lower() == "all":
|
||||||
amount[0] = user[1]
|
amount[0] = user[1]
|
||||||
|
|
||||||
amount[0] = float(amount[0])
|
amount[0] = float(amount[0])
|
||||||
|
|
|
@ -116,7 +116,7 @@ class Events(commands.Cog):
|
||||||
elif isinstance(err, (commands.ChannelNotFound, commands.ChannelNotReadable)):
|
elif isinstance(err, (commands.ChannelNotFound, commands.ChannelNotReadable)):
|
||||||
await ctx.send("Geen channel gevonden dat overeenkomt met het opgegeven argument.")
|
await ctx.send("Geen channel gevonden dat overeenkomt met het opgegeven argument.")
|
||||||
# Someone forgot an argument or passed an invalid argument
|
# Someone forgot an argument or passed an invalid argument
|
||||||
elif isinstance(err, (commands.BadArgument, commands.MissingRequiredArgument)):
|
elif isinstance(err, (commands.BadArgument, commands.MissingRequiredArgument, commands.UnexpectedQuoteError)):
|
||||||
await ctx.send("Controleer je argumenten.")
|
await ctx.send("Controleer je argumenten.")
|
||||||
else:
|
else:
|
||||||
# Remove the InvokeCommandError because it's useless information
|
# Remove the InvokeCommandError because it's useless information
|
||||||
|
|
|
@ -55,13 +55,13 @@ def isValidAmount(ctx, amount):
|
||||||
if not amount:
|
if not amount:
|
||||||
return [False, "Geef een geldig bedrag op."]
|
return [False, "Geef een geldig bedrag op."]
|
||||||
dinks = float(currency.dinks(ctx.author.id))
|
dinks = float(currency.dinks(ctx.author.id))
|
||||||
if amount == "all":
|
if str(amount).lower() == "all":
|
||||||
if dinks > 0:
|
if dinks > 0:
|
||||||
return [True, dinks]
|
return [True, dinks]
|
||||||
else:
|
else:
|
||||||
return [False, "Je hebt niet genoeg Didier Dinks om dit te doen."]
|
return [False, "Je hebt niet genoeg Didier Dinks om dit te doen."]
|
||||||
# Check if it's a number <= 0 or text != all
|
# Check if it's a number <= 0 or text != all
|
||||||
if (all(char.isalpha() for char in str(amount)) and amount != "all") or \
|
if (all(char.isalpha() for char in str(amount)) and str(amount).lower() != "all") or \
|
||||||
(all(char.isdigit() for char in str(abs(int(amount)))) and int(amount) <= 0):
|
(all(char.isdigit() for char in str(abs(int(amount)))) and int(amount) <= 0):
|
||||||
return [False, "Geef een geldig bedrag op."]
|
return [False, "Geef een geldig bedrag op."]
|
||||||
if int(amount) > dinks:
|
if int(amount) > dinks:
|
||||||
|
|
Loading…
Reference in New Issue