From 7343aa1c9b7faf1166d04a4855a45ee3e7f8dd62 Mon Sep 17 00:00:00 2001 From: BigGamerGary Date: Sat, 22 Apr 2023 16:17:41 +1000 Subject: [PATCH] Calculator --- Acronymbot.py | 147 +++++++++++++++++++++++++++++ __pycache__/Ledger.cpython-310.pyc | Bin 1912 -> 2742 bytes ledger.db-journal | Bin 0 -> 4616 bytes 3 files changed, 147 insertions(+) create mode 100644 ledger.db-journal diff --git a/Acronymbot.py b/Acronymbot.py index 5056586..9a77bd8 100644 --- a/Acronymbot.py +++ b/Acronymbot.py @@ -102,7 +102,154 @@ async def bal(interaction: discord.Interaction): ID = interaction.user.id data = cur.execute("SELECT * FROM ledger WHERE USERID = ?", (ID,)) await interaction.response.send_message(data) + +""" +#### Calculator #### +""" +class Calculator(discord.ui.View): + def __init__(self, *, timeout=180): + super().__init__(timeout=timeout) + self.numDigits = 0 + self.MAXIMUMBARSIZE = 30 + m = 0 + self.inputOne = 0 + self.inputTwo = 0 + self.expression = lambda x, y: x + self.output = 0 + self.digit = 1 + + @discord.ui.button(label="^", style=discord.ButtonStyle.red, row=4) + async def power(self, interaction: discord.Interaction, button: discord.ui.Button): + self.inputTwo = self.inputOne + self.inputOne = 0 + self.expression = lambda x, y: x ** y + await interaction.response.edit_message( + content=f"` {self.inputTwo} ^ 0`", + view=self) + + @discord.ui.button(label="0", style=discord.ButtonStyle.blurple,row=4) + async def zero(self, interaction: discord.Interaction, button: discord.ui.Button): + prevValue = self.inputOne + self.inputOne = self.inputOne * 10 + 0 + self.numDigits = self.numDigits + 1 + await interaction.response.edit_message(content="`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputOne}`") + + @discord.ui.button(label="1", style=discord.ButtonStyle.blurple, row=1) + async def one(self, interaction: discord.Interaction, button: discord.ui.Button): + prevValue = self.inputOne + self.inputOne = self.inputOne * 10 + 1 + self.numDigits = self.numDigits + 1 + await interaction.response.edit_message(content="`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputOne}`") + + + @discord.ui.button(label="2", style=discord.ButtonStyle.blurple, row=1) + async def two(self, interaction: discord.Interaction, button: discord.ui.Button): + prevValue = self.inputOne + self.inputOne = self.inputOne * 10 + 2 + self.numDigits = self.numDigits + 1 + await interaction.response.edit_message(content="`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputOne}`") + + @discord.ui.button(label="3", style=discord.ButtonStyle.blurple, row=1) + async def three(self, interaction: discord.Interaction, button: discord.ui.Button): + prevValue = self.inputOne + self.inputOne = self.inputOne * 10 + 3 + self.numDigits = self.numDigits + 1 + await interaction.response.edit_message(content="`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputOne}`") + + @discord.ui.button(label="4", style=discord.ButtonStyle.blurple, row=2) + async def four(self, interaction: discord.Interaction, button: discord.ui.Button): + prevValue = self.inputOne + self.inputOne = self.inputOne * 10 + 4 + self.numDigits = self.numDigits + 1 + await interaction.response.edit_message(content="`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputOne}`") + + @discord.ui.button(label="5", style=discord.ButtonStyle.blurple, row=2) + async def five(self, interaction: discord.Interaction, button: discord.ui.Button): + prevValue = self.inputOne + self.inputOne = self.inputOne * 10 + 5 + self.numDigits = self.numDigits + 1 + await interaction.response.edit_message(content="`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputOne}`") + + @discord.ui.button(label="6", style=discord.ButtonStyle.blurple, row=2) + async def six(self, interaction: discord.Interaction, button: discord.ui.Button): + prevValue = self.inputOne + self.inputOne = self.inputOne * 10 + 6 + self.numDigits = self.numDigits + 1 + await interaction.response.edit_message(content="`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputOne}`") + + @discord.ui.button(label="7", style=discord.ButtonStyle.blurple, row=3) + async def seven(self, interaction: discord.Interaction, button: discord.ui.Button): + prevValue = self.inputOne + self.inputOne = self.inputOne * 10 + 7 + self.numDigits = self.numDigits + 1 + await interaction.response.edit_message(content="`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputOne}`") + + @discord.ui.button(label="8", style=discord.ButtonStyle.blurple, row=3) + async def eight(self, interaction: discord.Interaction, button: discord.ui.Button): + prevValue = self.inputOne + self.inputOne = self.inputOne * 10 + 8 + self.numDigits = self.numDigits + 1 + await interaction.response.edit_message(content="`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputOne}`") + + @discord.ui.button(label="9", style=discord.ButtonStyle.blurple, row=3) + async def nine(self, interaction: discord.Interaction, button: discord.ui.Button): + prevValue = self.inputOne + self.inputOne = self.inputOne * 10 + 9 + self.numDigits = self.numDigits + 1 + await interaction.response.edit_message(content="`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputOne}`") + + @discord.ui.button(label="+", style=discord.ButtonStyle.red, row=1) + async def plus(self, interaction: discord.Interaction, button: discord.ui.Button): + self.inputTwo = self.inputOne + self.inputOne = 0 + self.expression = lambda x, y: x + y + await interaction.response.edit_message( + content=f"`" + " " * (self.MAXIMUMBARSIZE - self.numDigits) + f"{self.inputTwo} + 0`", + view=self) + @discord.ui.button(label="*", style=discord.ButtonStyle.red, row=2) + async def mult(self, interaction: discord.Interaction, button: discord.ui.Button): + self.inputTwo = self.inputOne + self.inputOne = 0 + self.expression = lambda x, y: x * y + await interaction.response.edit_message( + content=f"` {self.inputTwo} * 0`", + view=self) + + @discord.ui.button(label="-", style=discord.ButtonStyle.red, row=3) + async def minus(self, interaction: discord.Interaction, button: discord.ui.Button): + self.inputTwo = self.inputOne + self.inputOne = 0 + self.expression = lambda x, y: x - y + await interaction.response.edit_message( + content=f"` {self.inputTwo} - 0`", + view=self) + + @discord.ui.button(label="=", style=discord.ButtonStyle.green, row=4) + async def equals(self, interaction: discord.Interaction, button: discord.ui.Button): + self.output = self.expression(self.inputTwo, self.inputOne) + await interaction.response.edit_message( + content=f"` {self.output}`", + view=self) + + @discord.ui.button(label="/", style=discord.ButtonStyle.red, row=4) + async def divide(self, interaction: discord.Interaction, button: discord.ui.Button): + self.inputTwo = self.inputOne + self.inputOne = 0 + self.expression = lambda x, y: x / y + await interaction.response.edit_message( + content=f"` {self.inputTwo} / 0`", + view=self) + +@tree.command(description="Do Meth") +async def calculator(interaction: discord.Interaction): + await interaction.response.defer() + calculator = Calculator() + await interaction.followup.send(content="`" + " " * calculator.MAXIMUMBARSIZE + "0`", view=calculator) + + + + """ #### Fin #### """ diff --git a/__pycache__/Ledger.cpython-310.pyc b/__pycache__/Ledger.cpython-310.pyc index f80275d8c682d59bfc22caa43862264f78f4f5b9..6d254bab781723dc5977ddb59d4a4be935acaadc 100644 GIT binary patch literal 2742 zcmai0TXWk)6yDXvRvafyFHi~v779!RnM|Qil+xCXRR~R;Vmp+2!e|ujCKzNnS;^DJ z<31%bDUbXBX6ncM2L6ejnBj@PzzdwSl6-3hcINCJ?H=u(%eSA@U05g)XoojG=f4*S z`4b-|n*k4ZL82;joNyYD7Ws;BjqAsR>qlCP!jr*Gcrpb&(pwrY@ZvFP>B8XF&zfXH zKOz*~Y$&nk{(_xI&BuPS>F{tDBwB?|kQU_x_L}E9H;#>#&P`r`T@7C37K|pJ<0Tji zTx$@!oLE&a_IA8TBn2tro(yX~ZkRXJQPx1BW$0q^k`CyQ4v4D_$WPi!eMmqzKsR2R z18qpbWzrz0v}PBQVssF+V{s!X`rR-Tew=80Cn@+n8Fgi1a5y_Dif6*_#lqGTBND-G zVuW5tBxP_b5Nq8|#|!x>k&AHn-``YjZhL`v=51HIey=0KINE+ByL-~>fN~iB*bUj} z`Cd2PuK2PW9(H!RF{=ySd$zqH_@0of`-h3;y6vzXyDr8TK@CZnmgy4hpU+dWnp;ez z1S^Z8Qt}Qc5IQDB8_-=k)M)yw4aswTpf`v_TU(cNFi6BqV(p692Tz4<$a$D(mG))3 zizF}nYAS5+~s zTk5Vcc2^eh)PfI%Xve3z@;K4ftF8HV7zvqqI^(4IR6^Mo&`Ugfi7wLq;>bs}=;K1( zP)AXvKpdZt6S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