From 11381f8e80ccfd2d52271d266d7074ca78c40460 Mon Sep 17 00:00:00 2001 From: Interitio Date: Thu, 9 Nov 2023 13:51:05 +0200 Subject: [PATCH] fix(voicefix): Don't delete webhook on update. --- src/modules/voicefix/cog.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/modules/voicefix/cog.py b/src/modules/voicefix/cog.py index a3c8c7a..356701c 100644 --- a/src/modules/voicefix/cog.py +++ b/src/modules/voicefix/cog.py @@ -436,11 +436,14 @@ class VoiceFixCog(LionCog): return hook = discord.Webhook.from_url(webhook, client=self.bot) - await self.data.LinkHook.table.delete_where(channelid=channel.id) - await self.data.LinkHook.create( - channelid=channel.id, - webhookid=hook.id, - token=hook.token, - ) + existing = await self.data.LionHook.fetch(channel.id) + if existing: + await existing.update(webhookid=hook.id, token=hook.token) + else: + await self.data.LinkHook.create( + channelid=channel.id, + webhookid=hook.id, + token=hook.token, + ) self.hooks[channel.id] = hook await ctx.reply(f"Webhook for {channel.mention} updated!")