refactor: don't use query builder

This commit is contained in:
CyberL1 2025-09-29 07:44:25 +02:00 committed by Rory&
parent 29c4a6695c
commit 8e18a642fe

View File

@ -56,13 +56,9 @@ router.put(
// * in dm channels anyone can pin messages -> only check for guilds
if (message.guild_id) req.permission?.hasThrow("MANAGE_MESSAGES");
const pinned_count = await Message.createQueryBuilder("message")
.leftJoinAndSelect("message.channel", "channel")
.leftJoinAndSelect("message.author", "author")
.where("channel.id = :channelId", { channelId: channel_id })
.andWhere("message.pinned_at IS NOT NULL")
.orderBy("message.pinned_at", "DESC")
.getCount();
const pinned_count = await Message.count({
where: { channel: { id: channel_id }, pinned_at: Not(IsNull()) },
});
const { maxPins } = Config.get().limits.channel;
if (pinned_count >= maxPins)