From 71afe924e03d86dcdc37145c530847c629b76450 Mon Sep 17 00:00:00 2001 From: "Nyeki.py" <84998222+Nekidev@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:08:04 -0300 Subject: [PATCH] fix(bot): :ambulance: Hangup not working. --- payphone/cogs/calls/cog.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/payphone/cogs/calls/cog.py b/payphone/cogs/calls/cog.py index 317ada6..204cadd 100644 --- a/payphone/cogs/calls/cog.py +++ b/payphone/cogs/calls/cog.py @@ -466,20 +466,22 @@ class Calls(base.Cog): constants.CHANNELS_ONCALL_SET, str(channel_id), str(other_channel.id) ) - try: - await (await self.bot.get_or_fetch_channel(other_channel.id)).send( - f"☎️ {secrets.choice(constants.MSGS_PHONE_HANGUP_YOU)}" - ) + if other_channel is not None: + try: + await (await self.bot.get_or_fetch_channel(other_channel.id)).send( + f"☎️ {secrets.choice(constants.MSGS_PHONE_HANGUP_YOU)}" + ) - except errors.DiscordException: - pass + except errors.DiscordException: + pass + + other_channel.call = None await ctx.send(f"☎️ {secrets.choice(constants.MSGS_PHONE_HANGUP_ME)}") channel.call = None - other_channel.call = None - await models.Channel.bulk_update([channel, other_channel], ["call_id"]) + await models.Channel.bulk_update([channel] + ([other_channel] if other_channel is not None else []), ["call_id"]) call.ended_at = datetime.now(timezone.utc) await call.save()