diff --git a/Lagrange.OneBot/Core/Message/Entity/ReplySegment.cs b/Lagrange.OneBot/Core/Message/Entity/ReplySegment.cs index e36777589..aba4edd28 100644 --- a/Lagrange.OneBot/Core/Message/Entity/ReplySegment.cs +++ b/Lagrange.OneBot/Core/Message/Entity/ReplySegment.cs @@ -34,10 +34,16 @@ public override SegmentBase FromEntity(MessageChain chain, IMessageEntity entity { if (entity is not ForwardEntity forward || Database is null) throw new ArgumentException("The entity is not a forward entity."); + var collection = Database.GetCollection(); - var target = chain.IsGroup - ? collection.FindOne(x => x.Sequence == forward.Sequence && x.GroupUin == chain.GroupUin) - : collection.FindOne(x => x.Sequence == forward.Sequence && x.FriendUin == chain.FriendUin); + + uint friendUin = chain.FriendUin; // such action is to break the BsonExpression from MessageChain into uint + uint groupUin = chain.GroupUin ?? 0; + + var query = chain.IsGroup + ? collection.Query().Where(x => x.Sequence == forward.Sequence).Where(x => x.GroupUin == groupUin) + : collection.Query().Where(x => x.Sequence == forward.Sequence).Where(x => x.FriendUin == friendUin); + var target = query.First(); return new ReplySegment {