Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ tree = app_commands.CommandTree(bot)
|
|
| 15 |
|
| 16 |
luck_multipliers = {}
|
| 17 |
luck_expiration = {}
|
| 18 |
-
|
| 19 |
|
| 20 |
@app.get("/")
|
| 21 |
async def read_root():
|
|
@@ -155,26 +155,28 @@ async def perform_roll(interaction: discord.Interaction):
|
|
| 155 |
view = discord.ui.View()
|
| 156 |
view.add_item(roll_again_button)
|
| 157 |
|
| 158 |
-
if random.random() < 0.2
|
| 159 |
-
|
|
|
|
| 160 |
|
| 161 |
async def increase_luck_callback(interaction: discord.Interaction):
|
| 162 |
if interaction.user.id != user_id:
|
| 163 |
await interaction.response.send_message("cannot use", ephemeral=True)
|
| 164 |
return
|
| 165 |
|
| 166 |
-
if user_id in luck_used:
|
| 167 |
-
await interaction.response.send_message("You've already used your luck increase!", ephemeral=True)
|
| 168 |
-
return
|
| 169 |
-
|
| 170 |
current_luck = luck_multipliers.get(user_id, 1)
|
| 171 |
new_luck = min(current_luck + 1, 10)
|
| 172 |
luck_multipliers[user_id] = new_luck
|
| 173 |
luck_expiration[user_id] = time.time() + 1800
|
| 174 |
-
luck_used.add(user_id)
|
| 175 |
|
| 176 |
luck_percentage = (new_luck - 1) * 100
|
| 177 |
-
await interaction.response.send_message(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
increase_luck_button.callback = increase_luck_callback
|
| 180 |
view.add_item(increase_luck_button)
|
|
|
|
| 15 |
|
| 16 |
luck_multipliers = {}
|
| 17 |
luck_expiration = {}
|
| 18 |
+
luck_opportunities = {}
|
| 19 |
|
| 20 |
@app.get("/")
|
| 21 |
async def read_root():
|
|
|
|
| 155 |
view = discord.ui.View()
|
| 156 |
view.add_item(roll_again_button)
|
| 157 |
|
| 158 |
+
if random.random() < 0.2:
|
| 159 |
+
luck_opportunities[user_id] = luck_opportunities.get(user_id, 0) + 1
|
| 160 |
+
increase_luck_button = discord.ui.Button(style=discord.ButtonStyle.success, label="Increase Luck", custom_id=f"increase_luck_{luck_opportunities[user_id]}")
|
| 161 |
|
| 162 |
async def increase_luck_callback(interaction: discord.Interaction):
|
| 163 |
if interaction.user.id != user_id:
|
| 164 |
await interaction.response.send_message("cannot use", ephemeral=True)
|
| 165 |
return
|
| 166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
current_luck = luck_multipliers.get(user_id, 1)
|
| 168 |
new_luck = min(current_luck + 1, 10)
|
| 169 |
luck_multipliers[user_id] = new_luck
|
| 170 |
luck_expiration[user_id] = time.time() + 1800
|
|
|
|
| 171 |
|
| 172 |
luck_percentage = (new_luck - 1) * 100
|
| 173 |
+
await interaction.response.send_message(f"luck increased to {luck_percentage}% for 30 minutes!", ephemeral=True)
|
| 174 |
+
|
| 175 |
+
for item in view.children:
|
| 176 |
+
if item.custom_id == interaction.custom_id:
|
| 177 |
+
view.remove_item(item)
|
| 178 |
+
break
|
| 179 |
+
await interaction.message.edit(view=view)
|
| 180 |
|
| 181 |
increase_luck_button.callback = increase_luck_callback
|
| 182 |
view.add_item(increase_luck_button)
|