mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 16:03:12 +00:00
refactor: Update coinflip command to handle invalid predictions
This commit is contained in:
parent
5c9f229019
commit
360454c152
2 changed files with 32 additions and 29 deletions
|
@ -79,18 +79,18 @@
|
|||
"case_type_field_value": "`{0}`",
|
||||
"case_type_field_value_with_duration": "`{0} ({1})`",
|
||||
"coinflip_correct_prediction_author": "Correct Prediction!",
|
||||
"coinflip_correct_prediction_description": "The coin landed on **{0}**. You predicted correctly!",
|
||||
"coinflip_flipping_animation_1": "\ud83e\ude79 Flipping...",
|
||||
"coinflip_flipping_animation_2": "\ud83e\ude79 Flipping..",
|
||||
"coinflip_flipping_animation_3": "\ud83e\ude79 Flipping.",
|
||||
"coinflip_flipping_author": "Flipping a Coin",
|
||||
"coinflip_flipping_description": "The coin is in the air...",
|
||||
"coinflip_correct_prediction_description": "the coin landed on **{0}**. You predicted correctly!",
|
||||
"coinflip_flipping_animation_1": "\ud83e\ude99 Flipping...",
|
||||
"coinflip_flipping_animation_2": "\ud83e\ude99 Flipping..",
|
||||
"coinflip_flipping_animation_3": "\ud83e\ude99 Flipping.",
|
||||
"coinflip_flipping_author": "flipping a Coin",
|
||||
"coinflip_flipping_description": "the coin is in the air...",
|
||||
"coinflip_invalid_prediction_author": "Invalid Prediction",
|
||||
"coinflip_invalid_prediction_description": "Please enter a valid prediction ('heads'/'h' or 'tails'/'t').",
|
||||
"coinflip_invalid_prediction_description": "please enter a valid prediction ('heads'/'h' or 'tails'/'t').",
|
||||
"coinflip_result_author": "Coin Flip Result",
|
||||
"coinflip_result_description": "The coin landed on **{0}**.",
|
||||
"coinflip_result_description": "the coin landed on **{0}**.",
|
||||
"coinflip_wrong_prediction_author": "Wrong Prediction",
|
||||
"coinflip_wrong_prediction_description": "The coin landed on **{0}**. Your prediction was incorrect.",
|
||||
"coinflip_wrong_prediction_description": "the coin landed on **{0}**. Your prediction was incorrect.",
|
||||
"config_author": "Server Configuration",
|
||||
"config_birthday_channel_set": "birthday announcements will be sent in {0}.",
|
||||
"config_birthday_module_already_disabled": "the birthday module was already disabled.",
|
||||
|
|
|
@ -36,6 +36,18 @@ class Coinflip(commands.Cog):
|
|||
"""
|
||||
result = random.choice(["heads", "tails"])
|
||||
|
||||
if prediction:
|
||||
prediction = prediction.lower()
|
||||
if prediction not in ["heads", "h", "tails", "t"]:
|
||||
embed = Builder.create_embed(
|
||||
Builder.ERROR,
|
||||
user_name=ctx.author.name,
|
||||
author_text=CONST.STRINGS["coinflip_invalid_prediction_author"],
|
||||
description=CONST.STRINGS["coinflip_invalid_prediction_description"],
|
||||
)
|
||||
await ctx.send(embed=embed)
|
||||
return
|
||||
|
||||
flip_embed = Builder.create_embed(
|
||||
Builder.INFO,
|
||||
user_name=ctx.author.name,
|
||||
|
@ -61,31 +73,22 @@ class Coinflip(commands.Cog):
|
|||
await asyncio.sleep(0.5)
|
||||
|
||||
if prediction:
|
||||
prediction = prediction.lower()
|
||||
if prediction in ["heads", "h", "tails", "t"]:
|
||||
predicted_correctly = (prediction.startswith("h") and result == "heads") or (
|
||||
prediction.startswith("t") and result == "tails"
|
||||
predicted_correctly = (prediction.startswith("h") and result == "heads") or (
|
||||
prediction.startswith("t") and result == "tails"
|
||||
)
|
||||
if predicted_correctly:
|
||||
embed = Builder.create_embed(
|
||||
Builder.SUCCESS,
|
||||
user_name=ctx.author.name,
|
||||
author_text=CONST.STRINGS["coinflip_correct_prediction_author"],
|
||||
description=CONST.STRINGS["coinflip_correct_prediction_description"].format(result),
|
||||
)
|
||||
if predicted_correctly:
|
||||
embed = Builder.create_embed(
|
||||
Builder.SUCCESS,
|
||||
user_name=ctx.author.name,
|
||||
author_text=CONST.STRINGS["coinflip_correct_prediction_author"],
|
||||
description=CONST.STRINGS["coinflip_correct_prediction_description"].format(result),
|
||||
)
|
||||
else:
|
||||
embed = Builder.create_embed(
|
||||
Builder.ERROR,
|
||||
user_name=ctx.author.name,
|
||||
author_text=CONST.STRINGS["coinflip_wrong_prediction_author"],
|
||||
description=CONST.STRINGS["coinflip_wrong_prediction_description"].format(result),
|
||||
)
|
||||
else:
|
||||
embed = Builder.create_embed(
|
||||
Builder.ERROR,
|
||||
user_name=ctx.author.name,
|
||||
author_text=CONST.STRINGS["coinflip_invalid_prediction_author"],
|
||||
description=CONST.STRINGS["coinflip_invalid_prediction_description"],
|
||||
author_text=CONST.STRINGS["coinflip_wrong_prediction_author"],
|
||||
description=CONST.STRINGS["coinflip_wrong_prediction_description"].format(result),
|
||||
)
|
||||
else:
|
||||
embed = Builder.create_embed(
|
||||
|
|
Loading…
Reference in a new issue