From 0e9bf0001cc13a1a3b2bed09c3e594793bea1ff8 Mon Sep 17 00:00:00 2001
From: dnns01 <git@dnns01.de>
Date: Thu, 7 Sep 2023 22:17:28 +0200
Subject: [PATCH] Update libs and fix appointments and polls

---
 .idea/misc.xml             |  2 +-
 .idea/xanathar.iml         |  2 +-
 extensions/appointments.py |  7 ++++---
 extensions/polls.py        |  4 ++--
 requirements.txt           | 20 ++++++++++----------
 views/appointment_view.py  | 16 ++++------------
 views/poll_view.py         | 14 ++++----------
 7 files changed, 26 insertions(+), 39 deletions(-)
 mode change 100755 => 100644 .idea/misc.xml

diff --git a/.idea/misc.xml b/.idea/misc.xml
old mode 100755
new mode 100644
index 54ccbde..edbccd1
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (xanathar)" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (xanathar)" project-jdk-type="Python SDK" />
 </project>
\ No newline at end of file
diff --git a/.idea/xanathar.iml b/.idea/xanathar.iml
index f9707cc..4598eac 100644
--- a/.idea/xanathar.iml
+++ b/.idea/xanathar.iml
@@ -4,7 +4,7 @@
     <content url="file://$MODULE_DIR$">
       <excludeFolder url="file://$MODULE_DIR$/venv" />
     </content>
-    <orderEntry type="jdk" jdkName="Python 3.10 (xanathar)" jdkType="Python SDK" />
+    <orderEntry type="jdk" jdkName="Python 3.11 (xanathar)" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
 </module>
\ No newline at end of file
diff --git a/extensions/appointments.py b/extensions/appointments.py
index 8fcd227..c902fda 100755
--- a/extensions/appointments.py
+++ b/extensions/appointments.py
@@ -1,4 +1,5 @@
 import asyncio
+import uuid
 from datetime import datetime, timedelta
 import os
 
@@ -89,7 +90,7 @@ class Appointments(commands.GroupCog, name="appointments", description="Handle A
                                          reminder_sent=reminder == 0, uuid=uuid.uuid4())
 
         await interaction.response.send_message(embed=appointment.get_embed(), view=AppointmentView())
-        message = await interaction.original_message()
+        message = await interaction.original_response()
         Appointment.update(message=message.id).where(Appointment.id == appointment.id).execute()
 
     @app_commands.command(name="list", description="Listet alle Termine dieses Kanals auf.")
@@ -110,9 +111,9 @@ class Appointments(commands.GroupCog, name="appointments", description="Handle A
                 except errors.NotFound:
                     appointment.delete_instance(recursive=True)
 
-            await interaction.edit_original_message(content=answer)
+            await interaction.edit_original_response(content=answer)
         else:
-            await interaction.edit_original_message(content="Für diesen Channel existieren derzeit keine Termine")
+            await interaction.edit_original_response(content="Für diesen Channel existieren derzeit keine Termine")
 
 
 async def setup(bot: commands.Bot) -> None:
diff --git a/extensions/polls.py b/extensions/polls.py
index 30788bf..c442255 100755
--- a/extensions/polls.py
+++ b/extensions/polls.py
@@ -42,13 +42,13 @@ class Polls(commands.GroupCog, name="poll", description="Handle Polls in Channel
                    choice]
 
         await interaction.response.send_message("Bereite Umfrage vor, bitte warten...", view=PollView())
-        message = await interaction.original_message()
+        message = await interaction.original_response()
         poll = Poll.create(question=question, author=interaction.user.id, channel=interaction.channel_id,
                            message=message.id)
         for choice in choices:
             PollChoice.create(poll_id=poll.id, emoji=choice[0], text=choice[1])
 
-        await interaction.edit_original_message(content="", embed=poll.get_embed(), view=PollView())
+        await interaction.edit_original_response(content="", embed=poll.get_embed(), view=PollView())
 
     def parse_choice(self, idx: int, choice: str):
         choice = choice.strip()
diff --git a/requirements.txt b/requirements.txt
index 269f295..30f2165 100755
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,13 +1,13 @@
 aiohttp==3.8.5
-aiosignal==1.2.0
-async-timeout==4.0.2
-attrs==21.4.0
-charset-normalizer==2.1.0
+aiosignal==1.3.1
+async-timeout==4.0.3
+attrs==23.1.0
+charset-normalizer==3.2.0
 discord.py==2.3.2
 emoji==2.8.0
-frozenlist==1.3.0
-idna==3.3
-multidict==6.0.2
-peewee==3.15.2
-python-dotenv==0.20.0
-yarl==1.7.2
+frozenlist==1.4.0
+idna==3.4
+multidict==6.0.4
+peewee==3.16.3
+python-dotenv==1.0.0
+yarl==1.9.2
diff --git a/views/appointment_view.py b/views/appointment_view.py
index e09dd09..adbcc1d 100644
--- a/views/appointment_view.py
+++ b/views/appointment_view.py
@@ -10,9 +10,7 @@ class AppointmentView(discord.ui.View):
 
     @discord.ui.button(label='Zusagen', style=discord.ButtonStyle.green, custom_id='appointment_view:accept', emoji="👍")
     async def accept(self, interaction: discord.Interaction, button: discord.ui.Button):
-        appointment = Appointment.select().where(Appointment.message == interaction.message.id)
-        if appointment:
-            appointment = appointment[0]
+        if appointment := Appointment.get_or_none(Appointment.message == interaction.message.id):
             attendee = appointment.attendees.filter(member_id=interaction.user.id)
             if attendee:
                 await interaction.response.send_message("Du bist bereits Teilnehmerin dieses Termins.",
@@ -26,9 +24,7 @@ class AppointmentView(discord.ui.View):
 
     @discord.ui.button(label='Absagen', style=discord.ButtonStyle.red, custom_id='appointment_view:decline', emoji="👎")
     async def decline(self, interaction: discord.Interaction, button: discord.ui.Button):
-        appointment = Appointment.select().where(Appointment.message == interaction.message.id)
-        if appointment:
-            appointment = appointment[0]
+        if appointment := Appointment.get_or_none(Appointment.message == interaction.message.id):
             attendee = appointment.attendees.filter(member_id=interaction.user.id)
             if attendee:
                 attendee = attendee[0]
@@ -44,18 +40,14 @@ class AppointmentView(discord.ui.View):
     @discord.ui.button(label='Download .ics', style=discord.ButtonStyle.blurple, custom_id='appointment_view:ics',
                        emoji="📅")
     async def ics(self, interaction: discord.Interaction, button: discord.ui.Button):
-        appointment = Appointment.select().where(Appointment.message == interaction.message.id)
-        if appointment:
-            appointment = appointment[0]
+        if appointment := Appointment.get_or_none(Appointment.message == interaction.message.id):
             await interaction.response.send_message("", file=File(appointment.get_ics_file(),
                                                                   filename=f"{appointment.title}_{appointment.uuid}.ics"), ephemeral=True)
 
     @discord.ui.button(label='Löschen', style=discord.ButtonStyle.gray, custom_id='appointment_view:delete', emoji="🗑")
     async def delete(self, interaction: discord.Interaction, button: discord.ui.Button):
         await interaction.response.defer(thinking=False)
-        appointment = Appointment.select().where(Appointment.message == interaction.message.id)
-        if appointment:
-            appointment = appointment[0]
+        if appointment := Appointment.get_or_none(Appointment.message == interaction.message.id):
             if interaction.user.id == appointment.author:
                 appointment.delete_instance(recursive=True)
                 await interaction.message.delete()
diff --git a/views/poll_view.py b/views/poll_view.py
index 583e14b..cbe2dc9 100644
--- a/views/poll_view.py
+++ b/views/poll_view.py
@@ -9,9 +9,7 @@ class PollView(discord.ui.View):
 
     @discord.ui.button(label='Abstimmen', style=discord.ButtonStyle.green, custom_id='poll_view:vote', emoji="✅")
     async def vote(self, interaction: discord.Interaction, button: discord.ui.Button):
-        poll = Poll.select().where(Poll.message == interaction.message.id)
-        if poll:
-            poll = poll[0]
+        if poll := Poll.get_or_none(Poll.message == interaction.message.id):
             await interaction.response.send_message(f"{poll.question}\n\n*(Nach der Abstimmung kannst du diese Nachricht "
                                                     f"verwerfen. Wenn die Abstimmung nicht funktioniert, bitte verwirf "
                                                     f"die Nachricht und Klicke erneut auf den Abstimmen Button der "
@@ -21,19 +19,15 @@ class PollView(discord.ui.View):
     @discord.ui.button(label='Beenden', style=discord.ButtonStyle.gray, custom_id='poll_view:close', emoji="🛑")
     async def close(self, interaction: discord.Interaction, button: discord.ui.Button):
         await interaction.response.defer(thinking=False)
-        poll = Poll.select().where(Poll.message == interaction.message.id)
-        if poll:
-            poll = poll[0]
+        if poll := Poll.get_or_none(Poll.message == interaction.message.id):
             if interaction.user.id == poll.author:
                 poll.delete_instance(recursive=True)
-                await interaction.edit_original_message(view=None)
+                await interaction.edit_original_response(view=None)
 
     @discord.ui.button(label='Löschen', style=discord.ButtonStyle.gray, custom_id='poll_view:delete', emoji="🗑")
     async def delete(self, interaction: discord.Interaction, button: discord.ui.Button):
         await interaction.response.defer(thinking=False)
-        poll = Poll.select().where(Poll.message == interaction.message.id)
-        if poll:
-            poll = poll[0]
+        if poll := Poll.get_or_none(Poll.message == interaction.message.id):
             if interaction.user.id == poll.author:
                 poll.delete_instance(recursive=True)
                 await interaction.message.delete()
-- 
GitLab