From 4d06064963adc77b285dadda8f68bdd7e01e2d56 Mon Sep 17 00:00:00 2001 From: 4njru Date: Wed, 24 Jul 2024 14:09:13 -0400 Subject: [PATCH] Emojistory fixes; few more discrims nixed; oops fixed give/bal commands too --- crimsobot/cogs/games.py | 51 ++++++++++++++++++++++----------- crimsobot/data/games/rules.yaml | 2 +- crimsobot/handlers/games.py | 6 ++-- reload | 0 4 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 reload diff --git a/crimsobot/cogs/games.py b/crimsobot/cogs/games.py index 4e97c050..dd48a9d5 100644 --- a/crimsobot/cogs/games.py +++ b/crimsobot/cogs/games.py @@ -111,7 +111,7 @@ async def crimsoball(self, ctx: commands.Context, *, question: str) -> None: thumb_name='8ball', ) embed.add_field( - name='{} asks:'.format(ctx.message.author), + name=f'{ctx.message.author.name} asks:', value=question, inline=False ) @@ -324,7 +324,7 @@ async def emojistory(self, ctx: CrimsoContext) -> None: elif len(submissions.stories) == 1: title = '**WINNER BY DEFAULT!**' descr = '\n\n'.join([ - 'Only one submission by **{}**:'.format(submissions.stories[0].author), + f'Only one submission by **{submissions.stories[0].author.name}**:', emojis, submissions.stories[0].content, ]) @@ -377,7 +377,7 @@ async def emojistory(self, ctx: CrimsoContext) -> None: # then the embed info title = '**EMOJI STORY WINNER!**' descr = '\n\n'.join([ - f'The winner is **{winner.author}** with {votes_for_winner} vote{s_or_no_s} for their story:', + f'The winner is **{winner.author.name}** with {votes_for_winner} vote{s_or_no_s} for their story:', emojis, winner.content, ]) @@ -387,7 +387,7 @@ async def emojistory(self, ctx: CrimsoContext) -> None: title=title, descr=descr, thumb_name='random', - footer=f'{winner.author} gets {winning_amount} crimsoCOIN!' if winner else None, + footer=f'{winner.author.name} gets {winning_amount:.2f} crimsoCOIN!' if winner else None, ) await ctx.send(embed=embed) @@ -412,9 +412,13 @@ async def balance(self, ctx: commands.Context, whose: Optional[discord.Member] = bal = await crimsogames.check_balance(whose) + balance_negative = True if bal < 0 else False + neg = '-' if balance_negative else '' # negative sign on amount below if need be + embed = c.crimbed( - title=f'\u200B\n{whose} has **\u20A2{bal:.2f}**.', - descr=random.choice(encourage) if bal > 0 else '=[', + title=random.choice(encourage) if not balance_negative else '=[', + descr=f"{whose.name}'s balance is\n**{neg}\u20A2{abs(bal):.2f}**.", + footer='Earn more by playing games! See >help games.', thumb_name='crimsoCOIN', ) @@ -433,8 +437,9 @@ async def give(self, ctx: commands.Context, recipient: discord.Member, amount: f raise commands.BadArgument('Amount less than 0.') elif amount > await crimsogames.check_balance(ctx.message.author) * 0.25: embed = c.crimbed( - title=f'\u200B\n{ctx.message.author}, you cannot give more than 1/4 of your balance!', - descr='Check your `>balance`.', + title='Hold up—', + descr=f'{ctx.message.author.name}, you cannot give away more than 1/4 of your balance at a time!', + footer='Check your >balance.', thumb_name='crimsoCOIN', ) await ctx.send(embed=embed) @@ -444,9 +449,15 @@ async def give(self, ctx: commands.Context, recipient: discord.Member, amount: f return # transaction + old_bal_give = await crimsogames.check_balance(ctx.message.author) + old_bal_rec = await crimsogames.check_balance(recipient) + await crimsogames.win(ctx.message.author, -amount) # credit await crimsogames.win(recipient, amount) # debit + new_bal_give = await crimsogames.check_balance(ctx.message.author) + new_bal_rec = await crimsogames.check_balance(recipient) + # message (embed) encourage = [ 'Nice!', @@ -459,9 +470,11 @@ async def give(self, ctx: commands.Context, recipient: discord.Member, amount: f ] embed = c.crimbed( - title='\u200B\n{} has given {} **\u20A2{:.2f}** crimsoCOIN.'.format(ctx.message.author, recipient, amount), - descr=random.choice(encourage), + title=random.choice(encourage), + descr=f'{ctx.message.author.name} has given {recipient.name} **\u20A2{amount:.2f}** crimsoCOIN.', thumb_name='crimsoCOIN', + footer=f'{ctx.message.author.name}: \u20A2{old_bal_give:.2f} ➡️ \u20A2{new_bal_give:.2f}\n' + f'{recipient.name}: \u20A2{old_bal_rec:.2f} ➡️ \u20A2{new_bal_rec:.2f}', ) await ctx.send(embed=embed) @@ -471,15 +484,19 @@ async def give(self, ctx: commands.Context, recipient: discord.Member, amount: f async def cgive(self, ctx: commands.Context, recipient: discord.Member, amount: float) -> None: """Manual adjustment of crimsoCOIN values.""" - # change to float - amount = float(amount) - + # transaction + old_bal_rec = await crimsogames.check_balance(recipient) await crimsogames.win(recipient, amount) # debit + new_bal_rec = await crimsogames.check_balance(recipient) + + amount_negative = True if amount < 0 else False + neg = '-' if amount_negative else '' # negative sign on amount below if need be + embed = c.crimbed( - title="\u200B\n{} has adjusted {}'s balance by {neg}\u20A2**{:.2f}**.".format( - ctx.message.author, recipient, abs(amount), neg='-' if amount < 0 else '' - ), - descr='Life is inherently unfair.' if amount < 0 else 'Rejoice in your good fortune!', + title='Life is inherently unfair.' if amount_negative else 'Rejoice in your good fortune!', + descr=f"{ctx.message.author.name} has adjusted {recipient.name}'s balance by " + f'**{neg}\u20A2{abs(amount):.2f}**.', + footer=f'{recipient.name}: \u20A2{old_bal_rec:.2f} ➡️ \u20A2{new_bal_rec:.2f}', thumb_name='crimsoCOIN', ) diff --git a/crimsobot/data/games/rules.yaml b/crimsobot/data/games/rules.yaml index eb9f4be8..8f346513 100644 --- a/crimsobot/data/games/rules.yaml +++ b/crimsobot/data/games/rules.yaml @@ -26,7 +26,7 @@ cringo: 4: 9 6: 9 emojistory: - join_timer: 63 + join_timer: 90 minimum_length: 5 maximum_length: 300 vote_timer: 45 diff --git a/crimsobot/handlers/games.py b/crimsobot/handlers/games.py index e7c3278f..06d319d6 100644 --- a/crimsobot/handlers/games.py +++ b/crimsobot/handlers/games.py @@ -77,10 +77,10 @@ async def on_event(self, message: discord.Message) -> None: # type: ignore embed = c.crimbed( title=None, - descr=f'**{message.author}** joined!', + descr='Story submitted!', ) - await self.context.send(embed=embed, delete_after=8) + await self.context.send(embed=embed, delete_after=5) @must_be_event('on_message') @@ -110,7 +110,7 @@ async def on_event(self, message: discord.Message) -> None: # type: ignore embed = c.crimbed( title=None, - descr=f'**{message.author}** voted.', + descr=f'**{message.author.name}** voted.', ) await self.context.send(embed=embed, delete_after=8) diff --git a/reload b/reload new file mode 100644 index 00000000..e69de29b