fix(bot): 🐛 Replies not working when message comes from outside the call.

This commit is contained in:
Nyeki.py
2024-10-18 13:48:12 -03:00
parent 91b3f7d14a
commit 05b123862f
5 changed files with 59 additions and 5 deletions
+1
View File
@@ -380,6 +380,7 @@ bot = Payphone()
bot.load_extension("payphone.cogs.admin.cog") bot.load_extension("payphone.cogs.admin.cog")
bot.load_extension("payphone.cogs.calls.cog") bot.load_extension("payphone.cogs.calls.cog")
bot.load_extension("payphone.cogs.easter.cog")
bot.load_extension("payphone.cogs.mods.cog") bot.load_extension("payphone.cogs.mods.cog")
bot.load_extension("payphone.cogs.users.cog") bot.load_extension("payphone.cogs.users.cog")
bot.load_extension("payphone.cogs.utility.cog") bot.load_extension("payphone.cogs.utility.cog")
+2 -2
View File
@@ -29,11 +29,11 @@ async def ReplyEmbed(
.select_related("profile", "channel", "propagation_channel") .select_related("profile", "channel", "propagation_channel")
) )
is_this_channel = message.id == reference.message_id
if message is None: if message is None:
return None return None
is_this_channel = message.id == reference.message_id
last_content: models.MessageContent | None = None last_content: models.MessageContent | None = None
for content in message.contents: for content in message.contents:
View File
+53
View File
@@ -0,0 +1,53 @@
import secrets
from discord.ext import commands
from tortoise import transactions
from payphone import bot
from payphone.db import models
from payphone.cogs import base
from payphone.core import constants
class Easter(base.Cog):
show_in_help = False
def __init__(self, bot_instance: bot.Payphone):
self.bot = bot_instance
@commands.command()
@transactions.atomic()
async def catmask(self, ctx: commands.Context) -> None:
"""
This is a secret command!
"""
await ctx.message.delete()
new_mask = secrets.choice(constants.CAT_MASKS_LIST)
channel_rs = (
await models.CallUserChannelRelationship.filter(
channel_id=ctx.channel.id, user_id=ctx.author.id
)
.limit(1)
.select_related("call")
.first()
)
if channel_rs is None or channel_rs.call.ended_at is not None:
return
channel_rs.mask = new_mask.value
await channel_rs.save()
def setup(b: bot.Payphone) -> None:
"""Load the cog into the bot.
Args:
b (bot.Payphone): The bot instance to load the cog into.
"""
b.add_cog(Easter(b))
+2 -2
View File
@@ -373,9 +373,9 @@ class Mods(base.Cog):
diff = value - prev_value diff = value - prev_value
rows_with_diff[stat_i].append( rows_with_diff[stat_i].append(
value f"{value:,}"
if diff == 0 if diff == 0
else (value, f"({"+" if diff > 0 else ""}{diff})") else (f"{value:,}", f"({"+" if diff > 0 else ""}{diff})")
) )
table = fmt.monospace_table( table = fmt.monospace_table(