From de285fefa9e0841d93f9dbac3ea882f6ba5ce584 Mon Sep 17 00:00:00 2001 From: jackra1n <45038833+jackra1n@users.noreply.github.com> Date: Sun, 10 Dec 2023 12:52:22 +0100 Subject: [PATCH] wip --- bot/cogs/karma.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/bot/cogs/karma.py b/bot/cogs/karma.py index c604ae3..b785efe 100644 --- a/bot/cogs/karma.py +++ b/bot/cogs/karma.py @@ -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): @@ -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( @@ -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'