Merge pull request #40 from Payphone-Bot/39-discorduserid-reply-converter-not-working-on-propagated-messages-during-call
fix(bot): 🐛 `DiscordUserID` replies not working on unflushed propagated messages.
This commit is contained in:
@@ -5,8 +5,11 @@ from discord.ext.commands import converter
|
||||
|
||||
from tortoise import expressions
|
||||
|
||||
import orjson
|
||||
|
||||
from payphone.db import models
|
||||
from payphone.core import exceptions
|
||||
from payphone.core import exceptions, constants
|
||||
from payphone.core.redis import redis
|
||||
|
||||
|
||||
class Timedelta(converter.Converter):
|
||||
@@ -74,7 +77,31 @@ class DiscordUserID(converter.Converter):
|
||||
if row is not None:
|
||||
return row.user_id
|
||||
|
||||
raise converter.BadArgument()
|
||||
channel = await models.Channel.get_or_none(id=ctx.channel.id)
|
||||
|
||||
if channel is None:
|
||||
raise converter.BadArgument()
|
||||
|
||||
original_message_id = await redis.hget(
|
||||
constants.CALL_MESSAGE_FROM_PROPAGATION_TEMPLATE
|
||||
% channel.call_id,
|
||||
ref.message_id,
|
||||
)
|
||||
|
||||
if original_message_id is None:
|
||||
raise converter.BadArgument()
|
||||
|
||||
original_message_json = await redis.hget(
|
||||
constants.CALL_MESSAGES_TEMPLATE % channel.call_id,
|
||||
int(original_message_id),
|
||||
)
|
||||
|
||||
if original_message_json is None:
|
||||
raise converter.BadArgument()
|
||||
|
||||
original_message_dict = orjson.loads(original_message_json)
|
||||
|
||||
return original_message_dict["user_id"]
|
||||
|
||||
return msg.author.id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user