Skip to content

Commit

Permalink
fix: reaction button filtering issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed Jan 3, 2024
1 parent 90f92f6 commit 9f40fe6
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/updater/ReactionUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ export default class ReactionUpdater extends Factory {
// add user to cooldown list
user.client.reactionCooldowns.set(user.id, Date.now() + 3000);

const originalMsg = (await db.broadcastedMessages.findFirst({
where: { messageId: reaction.message.id },
include: { originalMsg: { include: { hub: true, broadcastMsgs: true } } },
}))?.originalMsg;
const originalMsg = (
await db.broadcastedMessages.findFirst({
where: { messageId: reaction.message.id },
include: { originalMsg: { include: { hub: true, broadcastMsgs: true } } },
})
)?.originalMsg;

if (
!originalMsg?.hub ||
Expand Down Expand Up @@ -315,14 +317,17 @@ export default class ReactionUpdater extends Factory {
})
.catch(() => null);


// FIXME: Fix not being able to react to messages with no reply button
const components = message?.components?.filter((row) => {
// filter all buttons that are not reaction buttons
row.components = row.components.filter((component) => {
return component.type === ComponentType.Button &&
component.style === ButtonStyle.Secondary
? !component.custom_id.startsWith('reaction_') &&
component.custom_id !== 'reaction_:view_all'
: true;
const isButton = component.type === ComponentType.Button;
if (isButton && component.style === ButtonStyle.Secondary) {
const custom_id = CustomID.parseCustomId(component.custom_id);
return custom_id.prefix !== 'reaction_' && custom_id.suffix !== 'view_all';
}
return true;
});

// if the filtered row has components, that means it has components other than reaction buttons
Expand Down

0 comments on commit 9f40fe6

Please sign in to comment.