Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jackra1n committed Dec 20, 2023
1 parent fc1859d commit de285fe
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions bot/cogs/karma.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ def __init__(self, ctx: commands.Context, kasino: Record):
super().__init__(timeout=None)
self.ctx = ctx
self.kasino = kasino
self.add_item(KasinoBetButton(ctx, kasino))


class KasinoBetButton(ui.Button):
Expand All @@ -899,8 +900,8 @@ def __init__(self, ctx: commands.Context, kasino: Record):
self.bet_option_select = discord.ui.Select(
placeholder='Select option',
options=[
discord.SelectOption(label=kasino['option_1'], value='1'),
discord.SelectOption(label=kasino['option_2'], value='2')
discord.SelectOption(label=kasino['option1'], value='1'),
discord.SelectOption(label=kasino['option2'], value='2')
]
)
self.bet_amount_input = discord.ui.TextInput(
Expand All @@ -923,25 +924,16 @@ async def on_submit(self, interaction: discord.Interaction) -> None:
if amount < 1:
return await interaction.response.send_message('You tried to bet < 1 karma! Silly you!', ephemeral=True)

kasino = await self.bot.db.fetchrow('SELECT * FROM kasino WHERE id = $1', kasino_id)

if kasino is None:
output_embed.title=f'Kasino with ID {kasino_id} is not open.'
return await ctx.author.send(embed=output_embed, delete_after=30)
if self.kasino['locked']:
return await interaction.response.send_message('The kasino is locked! No more bets are taken in. Time to wait and see...', ephemeral=True)

if kasino['locked']:
output_embed.title=f'kasino with ID {kasino_id} is locked.'
return await ctx.author.send(embed=output_embed, delete_after=30)

bettor_karma = await self._get_user_karma(ctx.author.id, ctx.guild.id)
bettor_karma = await self._get_user_karma(interaction.user.id, interaction.guild.id)
if bettor_karma is None:
return await ctx.send('You do not have any karma.')
return await interaction.response.send_message('You don\'t have any karma!', ephemeral=True)

amount = bettor_karma if amount == "all" else amount

if bettor_karma < amount:
output_embed.title=f'You don\'t have that much karma. Your karma: {bettor_karma}'
return await ctx.author.send(embed=output_embed, delete_after=30)
return await interaction.response.send_message('You don\'t have enough karma!', ephemeral=True)

total_bet = amount
output = 'added'
Expand Down

0 comments on commit de285fe

Please sign in to comment.