APRK01 commited on
Commit
90fc18c
Β·
1 Parent(s): 0740360

fix: make verify work without stored message ID (Railway DB resets)

Browse files
Files changed (1) hide show
  1. src/systems/verification.js +19 -2
src/systems/verification.js CHANGED
@@ -40,10 +40,20 @@ async function sendVerificationEmbed(client) {
40
 
41
  /**
42
  * Handle verification reaction add.
 
43
  */
44
  async function handleVerifyReaction(reaction, user, client) {
 
 
 
 
 
 
45
  const verifyMsgId = stmts.getState.get('verify_message_id')?.value;
46
- if (!verifyMsgId || reaction.message.id !== verifyMsgId) return false;
 
 
 
47
  if (reaction.emoji.name !== 'βœ…') return false;
48
 
49
  const guild = reaction.message.guild;
@@ -62,8 +72,15 @@ async function handleVerifyReaction(reaction, user, client) {
62
  * Handle verification reaction remove.
63
  */
64
  async function handleVerifyReactionRemove(reaction, user, client) {
 
 
 
 
65
  const verifyMsgId = stmts.getState.get('verify_message_id')?.value;
66
- if (!verifyMsgId || reaction.message.id !== verifyMsgId) return false;
 
 
 
67
  if (reaction.emoji.name !== 'βœ…') return false;
68
 
69
  const guild = reaction.message.guild;
 
40
 
41
  /**
42
  * Handle verification reaction add.
43
+ * Works by checking channel name OR stored message ID (resilient to DB resets).
44
  */
45
  async function handleVerifyReaction(reaction, user, client) {
46
+ // Check if this is a reaction in the verify channel on a bot message
47
+ const channel = reaction.message.channel;
48
+ const isVerifyChannel = channel.name === 'βœ…γƒ»verify';
49
+ const isBotMessage = reaction.message.author?.id === client.user.id;
50
+
51
+ // Also check stored message ID as fallback
52
  const verifyMsgId = stmts.getState.get('verify_message_id')?.value;
53
+ const isStoredMsg = verifyMsgId && reaction.message.id === verifyMsgId;
54
+
55
+ if (!isVerifyChannel && !isStoredMsg) return false;
56
+ if (isVerifyChannel && !isBotMessage) return false;
57
  if (reaction.emoji.name !== 'βœ…') return false;
58
 
59
  const guild = reaction.message.guild;
 
72
  * Handle verification reaction remove.
73
  */
74
  async function handleVerifyReactionRemove(reaction, user, client) {
75
+ const channel = reaction.message.channel;
76
+ const isVerifyChannel = channel.name === 'βœ…γƒ»verify';
77
+ const isBotMessage = reaction.message.author?.id === client.user.id;
78
+
79
  const verifyMsgId = stmts.getState.get('verify_message_id')?.value;
80
+ const isStoredMsg = verifyMsgId && reaction.message.id === verifyMsgId;
81
+
82
+ if (!isVerifyChannel && !isStoredMsg) return false;
83
+ if (isVerifyChannel && !isBotMessage) return false;
84
  if (reaction.emoji.name !== 'βœ…') return false;
85
 
86
  const guild = reaction.message.guild;