fix(bot): 🐛 Attempt to fix p.hangup.
This commit is contained in:
@@ -173,6 +173,10 @@ class Calls(base.Cog):
|
||||
i += 1
|
||||
|
||||
if other_channel_id in last_calls_other_channels_ids:
|
||||
await self.bot.redis.sadd(
|
||||
constants.CHANNELS_SEARCH_QUEUE, str(other_channel_id)
|
||||
)
|
||||
|
||||
other_channel_id = await self.bot.redis.spop(
|
||||
constants.CHANNELS_SEARCH_QUEUE
|
||||
)
|
||||
@@ -180,9 +184,6 @@ class Calls(base.Cog):
|
||||
if other_channel_id is None:
|
||||
break
|
||||
|
||||
await self.bot.redis.sadd(
|
||||
constants.CHANNELS_SEARCH_QUEUE, str(other_channel_id)
|
||||
)
|
||||
continue
|
||||
|
||||
break
|
||||
@@ -354,12 +355,17 @@ class Calls(base.Cog):
|
||||
i += 1
|
||||
|
||||
if other_channel_id in last_calls_other_channels_ids:
|
||||
other_channel_id = await self.bot.redis.spop(
|
||||
constants.CHANNELS_SEARCH_QUEUE
|
||||
)
|
||||
await self.bot.redis.sadd(
|
||||
constants.CHANNELS_SEARCH_QUEUE, str(other_channel_id)
|
||||
)
|
||||
|
||||
other_channel_id = await self.bot.redis.spop(
|
||||
constants.CHANNELS_SEARCH_QUEUE
|
||||
)
|
||||
|
||||
if other_channel_id is None:
|
||||
break
|
||||
|
||||
continue
|
||||
|
||||
break
|
||||
|
||||
+13
-4
@@ -5,19 +5,28 @@ import discord
|
||||
from payphone.db import models
|
||||
|
||||
|
||||
async def get_channel(channel: discord.TextChannel) -> models.Channel:
|
||||
async def get_channel(
|
||||
channel: discord.TextChannel, for_update: bool = False
|
||||
) -> models.Channel:
|
||||
"""Returns a channel from the database, creating or updating it if it already exists.
|
||||
|
||||
Args:
|
||||
channel (discord.TextChannel): The channel to fetch.
|
||||
for_update (bool, optional): Whether the select should be FOR UPDATE or not.
|
||||
|
||||
Returns:
|
||||
models.Channel: The channel row.
|
||||
"""
|
||||
|
||||
row, _ = await models.Channel.update_or_create(
|
||||
id=channel.id, server=channel.guild.id
|
||||
)
|
||||
model = models.Channel
|
||||
|
||||
if for_update:
|
||||
model = model.select_for_update()
|
||||
|
||||
row = await model.get_or_none(id=channel.id)
|
||||
|
||||
if row is None:
|
||||
row = await models.Channel.create(id=channel.id, server_id=channel.guild.id)
|
||||
|
||||
channel_name = channel.name.replace("discord", "d").replace("wumpus", "w")
|
||||
webhook_name = f"Payphone #{channel_name}"
|
||||
|
||||
Reference in New Issue
Block a user