Skip to content

Commit 3834b6f

Browse files
committed
Self-Vote logging
1 parent 67b789a commit 3834b6f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

events/Message/messageReactionAdd.mjs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ export async function run(client, messageReaction, user) {
112112
try {
113113
const originalMsg = await originalChannel.messages.fetch(originalMsgId).catch(() => null);
114114
if (originalMsg) {
115+
// Check if the reaction is from the original author and if self-vote is disabled
116+
console.log('starboardchannel Self-Vote', config['self-vote']);
117+
if (!config['self-vote'] && originalMsg.author.id === user.id) {
118+
if (config['remove-invalid-reactions']) {
119+
await messageReaction.users
120+
.remove(user.id)
121+
.catch(() => console.log(`Failed to remove self-vote reaction in starboard for user ${user.id}`));
122+
}
123+
continue;
124+
}
125+
115126
originalMsgUpvotes = findReactionCount(originalMsg.reactions.cache, config.emoji);
116127
}
117128
} catch (err) {
@@ -150,10 +161,16 @@ export async function run(client, messageReaction, user) {
150161
}
151162

152163
// Reaction on a regular message
164+
console.log('self-vote', config['self-vote']);
153165
if (!config['self-vote'] && msg.author.id === user.id) {
166+
console.log('inside self-vote');
154167
if (config['remove-invalid-reactions']) {
155-
await messageReaction.remove().catch(() => console.log('Failed to remove reaction'));
168+
console.log('inside remove reactions');
169+
await messageReaction.users
170+
.remove(user.id)
171+
.catch(() => console.log(`Failed to remove self-vote reaction in starboard for user ${user.id}`));
156172
}
173+
console.log('Skipping self-vote, should not send to starboard');
157174
continue;
158175
}
159176

0 commit comments

Comments
 (0)