diff --git a/extensions/appointments.py b/extensions/appointments.py index e6080da1dfcd213bcbb64b40b51649ac689b7e83..7ed69cbf6331fc28ae6cde5e6cd62502b54b0825 100644 --- a/extensions/appointments.py +++ b/extensions/appointments.py @@ -20,7 +20,10 @@ async def send_notification(appointment, channel): message += f"\n" message += " ".join([f"<@!{str(attendee.member_id)}>" for attendee in appointment.attendees]) - await channel.send(message) + if appointment.reminder_sent: + return await channel.send(message, embed=appointment.get_embed()) + + return await channel.send(message, embed=appointment.get_embed(), view=AppointmentView()) @app_commands.guild_only() @@ -41,11 +44,11 @@ class Appointments(commands.GroupCog, name="appointments", description="Handle A try: channel = await self.bot.fetch_channel(appointment.channel) message = await channel.fetch_message(appointment.message) - await send_notification(appointment, channel) + new_message = await send_notification(appointment, channel) + Appointment.update(message=new_message.id).where(Appointment.id == appointment.id).execute() + await message.delete() if appointment.reminder_sent: - await message.delete() - if appointment.recurring == 0: appointment.delete_instance(recursive=True) else: diff --git a/extensions/text_commands.py b/extensions/text_commands.py index 88dea00db1ac94a5eb0d40ef326e4011ec499f87..b119b30f2781d16f7c87241e5856447cdbd69f3d 100644 --- a/extensions/text_commands.py +++ b/extensions/text_commands.py @@ -56,8 +56,9 @@ class TextCommands(commands.GroupCog, name="commands", description="Text Command text="Text, der bei Benutzung des Commands ausgegeben werden soll.") async def cmd_add(self, interaction: Interaction, cmd: str, text: str): if not re.match(r"^[a-z0-9]+(-[a-z0-9]+)*$", cmd): - await interaction.edit_original_response( - content="Ein Command darf nur aus Kleinbuchstaben und Zahlen bestehen, die durch Bindestriche getrennt werden können.") + await interaction.response.send_message( + "Ein Command darf nur aus Kleinbuchstaben und Zahlen bestehen, die durch Bindestriche getrennt werden können.", + ephemeral=True) return command = Command.get_or_none(Command.command == cmd) @@ -127,7 +128,7 @@ class TextCommands(commands.GroupCog, name="commands", description="Text Command else: if self.exists(cmd): return False - command = Command.create(command=cmd, description=description) + command = Command.create(command=cmd, description=description, guild_id=guild_id) CommandText.create(text=text, command=command.id) await self.register_command(command) diff --git a/models.py b/models.py index dbee384b362b010576ebf26e8bd7c72d44b9a5c1..a7c41ba4dbc36c98f7a03c056db44e45371351c8 100644 --- a/models.py +++ b/models.py @@ -120,10 +120,13 @@ class Appointment(BaseModel): def get_embed(self): attendees = self.attendees + description = "" if self.reminder_sent else (f"Wenn du eine Benachrichtigung zum Beginn des Termins " + f"{f', sowie {self.reminder} Minuten vorher, ' if self.reminder > 0 else f''}" + f" erhalten möchtest, verwende den \"Zusagen\" Button unter dieser Nachricht." + f" Hast du bereits zugesagt und möchtest keine Benachrichtigung erhalten, " + f"kannst du den \"Absagen\" Button benutzen.") embed = discord.Embed(title=self.title, - description=f"Wenn du eine Benachrichtigung zum Beginn des Termins" - f"{f', sowie {self.reminder} Minuten vorher, ' if self.reminder > 0 else f''}" - f" erhalten möchtest, reagiere mit :thumbsup: auf diese Nachricht.", + description=description, color=19607) if len(self.description) > 0: diff --git a/requirements.txt b/requirements.txt index e7f2c8aaadc5e6026e0580615fc7e26ac44013c4..b5199bb767582025f0920fba07b79fd72c240ee8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ aiohttp==3.9.5 beautifulsoup4==4.12.3 discord.py==2.3.2 -emoji==2.11.1 -peewee==3.17.3 +emoji==2.12.1 +peewee==3.17.5 PyNaCl==1.5.0 python-dotenv==1.0.1 -requests==2.31.0 +requests==2.32.0 aiosignal==1.3.1 attrs==23.2.0