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
|
from tortoise import expressions
|
||||||
|
|
||||||
|
import orjson
|
||||||
|
|
||||||
from payphone.db import models
|
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):
|
class Timedelta(converter.Converter):
|
||||||
@@ -74,8 +77,32 @@ class DiscordUserID(converter.Converter):
|
|||||||
if row is not None:
|
if row is not None:
|
||||||
return row.user_id
|
return row.user_id
|
||||||
|
|
||||||
|
channel = await models.Channel.get_or_none(id=ctx.channel.id)
|
||||||
|
|
||||||
|
if channel is None:
|
||||||
raise converter.BadArgument()
|
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
|
return msg.author.id
|
||||||
|
|
||||||
user = await models.User.get_or_none(username=argument)
|
user = await models.User.get_or_none(username=argument)
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
shard_count = info["shards"]
|
shard_count = info["shards"]
|
||||||
|
|
||||||
|
print(f"Starting {shard_count} shard{"s" if shard_count != 1 else ""}.")
|
||||||
|
|
||||||
ps: list[mp.Process] = [
|
ps: list[mp.Process] = [
|
||||||
mp.Process(target=shard, args=(i, shard_count)) for i in range(shard_count)
|
mp.Process(target=shard, args=(i, shard_count)) for i in range(shard_count)
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user